Airport Guide Documentation

ScheduledBusController extends BaseController
in package

Scheduled Bus Management Controller

This controller handles all operations related to scheduled bus services at airports. It provides CRUD operations for managing scheduled bus companies, their contact information, and associated airport data. The controller includes features for listing, creating, editing, viewing, and deleting scheduled bus records with proper validation and admin activity logging.

Tags
author

Airport Guide System

version
1.0
since
2024

Table of Contents

Methods

__construct()  : void
Constructor for ScheduledBusController
create()  : View
Show the form for creating a new scheduled bus resource
destroy()  : RedirectResponse
Remove the specified scheduled bus resource from storage
edit()  : View|RedirectResponse
Show the form for editing the specified scheduled bus resource
getCityScheduled()  : JsonResponse
Get cities for a specific airport code
index()  : View|DataTable
Display a listing of scheduled bus resources
show()  : void
Display the specified scheduled bus resource
store()  : RedirectResponse
Store a newly created scheduled bus resource in storage
update()  : RedirectResponse
Update the specified scheduled bus resource in storage

Methods

__construct()

Constructor for ScheduledBusController

public __construct() : void

Initializes the controller by checking user authentication and permissions. Redirects to login if user is not authenticated or lacks proper permissions.

create()

Show the form for creating a new scheduled bus resource

public create(Request $request) : View

Displays the create form with necessary data for adding a new scheduled bus service. Prepares dropdown lists for airports, states, and other required fields.

Parameters
$request : Request

The HTTP request object

Tags
example

GET /admin/scheduledbus/create

Return values
View

Returns the create form view

destroy()

Remove the specified scheduled bus resource from storage

public destroy(int $id) : RedirectResponse

Deletes a scheduled bus record and creates an admin activity log entry. Performs soft delete if the model supports it, otherwise performs hard delete.

Parameters
$id : int

The ID of the scheduled bus record to delete

Tags
example

DELETE /admin/scheduledbus/123

Return values
RedirectResponse

Redirects to index with success message

edit()

Show the form for editing the specified scheduled bus resource

public edit(int $id, Request $request) : View|RedirectResponse

Displays the edit form for an existing scheduled bus record with security validation. Includes MD5 hash verification to prevent unauthorized access and maintains pagination state and search filters in the form.

Parameters
$id : int

The ID of the scheduled bus record to edit

$request : Request

The HTTP request object containing security key and pagination data

Tags
example

GET /admin/scheduledbus/123/edit?key=abc123&page_no=2

Return values
View|RedirectResponse

Returns edit form or redirects on security failure

getCityScheduled()

Get cities for a specific airport code

public getCityScheduled(Request $request) : JsonResponse

Retrieves cities associated with a specific airport code for dropdown population. This method is typically called via AJAX to populate city dropdowns dynamically. If an ID is provided, it also returns the current city name for the existing record.

Parameters
$request : Request

The HTTP request object containing airport and optional ID

Tags
example

GET /admin/scheduledbus/get-city-scheduled?airport=John F. Kennedy International Airport (JFK)&id=123

Response: { "name": "New York", "cities": [ {"city_name": "Brooklyn"}, {"city_name": "Manhattan"}, {"city_name": "Queens"} ] }

Return values
JsonResponse

Returns JSON response with cities and optional current city name

index()

Display a listing of scheduled bus resources

public index(Request $request) : View|DataTable

This method handles both AJAX and regular requests for displaying scheduled bus data. For AJAX requests, it returns DataTables formatted data with search and filtering capabilities. For regular requests, it returns a view with pagination and search filters.

Features:

  • Pagination support with configurable page size
  • Search filtering by company name, address, phone, airport name, and airport code
  • DataTables integration for enhanced user experience
  • Action buttons for view, edit, and delete operations
Parameters
$request : Request

The HTTP request object containing search parameters and pagination data

Tags
example

// Regular request GET /admin/scheduledbus

// AJAX request with search filters GET /admin/scheduledbus?ajax=1&company_name=ABC&airport_code=JFK

Return values
View|DataTable

Returns view for regular requests or DataTable for AJAX

show()

Display the specified scheduled bus resource

public show(int $id, Request $request) : void

Shows detailed information about a specific scheduled bus record in HTML format. This method is typically called via AJAX to display data in a modal window. Only displays fields that have values (non-empty).

Parameters
$id : int

The ID of the scheduled bus record to display

$request : Request

The HTTP request object

Tags
example

GET /admin/scheduledbus/123

Output:

Airport NameJohn F. Kennedy International Airport
Company NameABC Shuttle Service
Return values
void

Outputs HTML content directly to the response

store()

Store a newly created scheduled bus resource in storage

public store(Request $request) : RedirectResponse

Validates and stores a new scheduled bus record with the following features:

  • Validates required fields (airport_name)
  • Parses airport information from formatted string
  • Creates admin activity log entry
  • Handles airport code extraction and airport ID lookup
Parameters
$request : Request

The HTTP request object containing form data

Tags
throws
ValidationException

When validation fails

example

POST /admin/scheduledbus

Request data: { "airport_name": "John F. Kennedy International Airport (JFK)", "company_name": "ABC Shuttle Service", "company_address": "123 Main St, New York, NY", "company_phone1": "+1-555-123-4567", "city": "New York", "state": "NY", "zip_code": "10001" }

Return values
RedirectResponse

Redirects to index with success message

update()

Update the specified scheduled bus resource in storage

public update(Request $request, int $id) : RedirectResponse

Updates an existing scheduled bus record with validation and security features:

  • Validates required fields
  • Parses airport information from formatted string
  • Creates admin activity log entry
  • Maintains pagination and search filter state
  • Handles airport code extraction and airport ID lookup
Parameters
$request : Request

The HTTP request object containing form data

$id : int

The ID of the scheduled bus record to update

Tags
throws
ValidationException

When validation fails

example

PUT /admin/scheduledbus/123

Request data: { "airport_name": "John F. Kennedy International Airport (JFK)", "company_name": "Updated ABC Shuttle Service", "company_address": "456 Updated St, New York, NY", "company_phone1": "+1-555-987-6543", "city": "New York", "state": "NY", "zip_code": "10002" }

Return values
RedirectResponse

Redirects to index with success message and preserved filters


        
On this page

Search results