TransitController
extends BaseController
in package
Transit Service Management Controller
This controller handles all operations related to airport transit services management. It provides CRUD operations for managing transit companies, their contact information, routes, and associated airport data. The controller includes features for listing, creating, editing, viewing, and deleting transit service records with proper validation and admin activity logging.
Features:
- DataTables integration with search and filtering
- Airport code parsing and validation
- Security validation with MD5 hash verification
- Admin activity logging for all operations
- Status management (Active/Inactive)
- Route and place information handling
- Multiple contact methods support
Tags
Table of Contents
Methods
- __construct() : void
- Constructor for TransitController
- create() : View
- Show the form for creating a new transit service resource
- destroy() : RedirectResponse
- Remove the specified transit service resource from storage
- edit() : View|RedirectResponse
- Show the form for editing the specified transit service resource
- index() : View|DataTable
- Display a listing of transit service resources
- show() : void
- Display the specified transit service resource
- store() : RedirectResponse
- Store a newly created transit service resource in storage
- update() : RedirectResponse
- Update the specified transit service resource in storage
Methods
__construct()
Constructor for TransitController
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 transit service resource
public
create(Request $request) : View
Displays the create form with necessary data for adding a new transit service. Prepares dropdown lists for airports, states, and other required fields.
Parameters
- $request : Request
-
The HTTP request object
Tags
Return values
View —Returns the create form view
destroy()
Remove the specified transit service resource from storage
public
destroy(int $id) : RedirectResponse
Deletes a transit service 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 transit service record to delete
Tags
Return values
RedirectResponse —Redirects to index with success message
edit()
Show the form for editing the specified transit service resource
public
edit(int $id, Request $request) : View|RedirectResponse
Displays the edit form for an existing transit service 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 transit service record to edit
- $request : Request
-
The HTTP request object containing security key and pagination data
Tags
Return values
View|RedirectResponse —Returns edit form or redirects on security failure
index()
Display a listing of transit service resources
public
index(Request $request) : View|DataTable
This method handles both AJAX and regular requests for displaying transit service 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
- Case-insensitive search with ILIKE functions
- Status column display (Active/Inactive)
Parameters
- $request : Request
-
The HTTP request object containing search parameters and pagination data
Tags
Return values
View|DataTable —Returns view for regular requests or DataTable for AJAX
show()
Display the specified transit service resource
public
show(int $id, Request $request) : void
Shows detailed information about a specific transit service 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 transit service record to display
- $request : Request
-
The HTTP request object
Tags
Return values
void —Outputs HTML content directly to the response
store()
Store a newly created transit service resource in storage
public
store(Request $request) : RedirectResponse
Validates and stores a new transit service 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
- Supports multiple contact methods and route information
Parameters
- $request : Request
-
The HTTP request object containing form data
Tags
Return values
RedirectResponse —Redirects to index with success message
update()
Update the specified transit service resource in storage
public
update(Request $request, int $id) : RedirectResponse
Updates an existing transit service 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 transit service record to update
Tags
Return values
RedirectResponse —Redirects to index with success message and preserved filters