TransportationController
extends BaseController
in package
Public Transportation Management Controller
This controller handles all operations related to public transportation services at airports. It provides CRUD operations for managing transportation companies, their contact information, routes, pricing, and associated airport data. The controller includes features for listing, creating, editing, viewing, and deleting transportation records with proper validation, image processing, and admin activity logging.
Features:
- DataTables integration with search and filtering
- Image upload with thumbnail generation (200x200 with aspect ratio)
- Airport code parsing and validation
- Security validation with MD5 hash verification
- Admin activity logging for all operations
- City name formatting and processing
- Price management and route information
- Product URL and company description handling
- Organized file storage structure (YYYY/MM)
Tags
Table of Contents
Methods
- __construct() : void
- Constructor for TransportationController
- create() : View
- Show the form for creating a new public transportation resource
- deleteImage() : void
- Delete transportation image files
- destroy() : RedirectResponse
- Remove the specified public transportation resource from storage
- edit() : View|RedirectResponse
- Show the form for editing the specified public transportation resource
- getCity() : JsonResponse
- Get cities based on airport code
- index() : View|DataTable
- Display a listing of public transportation resources
- show() : void
- Display the specified public transportation resource
- store() : RedirectResponse
- Store a newly created public transportation resource in storage
- update() : RedirectResponse
- Update the specified public transportation resource in storage
Methods
__construct()
Constructor for TransportationController
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 public transportation resource
public
create(Request $request) : View
Displays the create form with necessary data for adding a new transportation 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
deleteImage()
Delete transportation image files
public
deleteImage(int $id) : void
Removes image files associated with a transportation record from the file system. Deletes both the main image and its thumbnail, then updates the database record to clear the image references.
Parameters
- $id : int
-
The ID of the transportation record
Tags
Return values
void —Outputs "true" on success or "false" on failure
destroy()
Remove the specified public transportation resource from storage
public
destroy(int $id) : RedirectResponse
Deletes a transportation record and associated image files, then creates an admin activity log entry. Performs cleanup of both main images and thumbnails from the file system.
Parameters
- $id : int
-
The ID of the transportation record to delete
Tags
Return values
RedirectResponse —Redirects to index with success message
edit()
Show the form for editing the specified public transportation resource
public
edit(int $id, Request $request) : View|RedirectResponse
Displays the edit form for an existing transportation 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 transportation 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
getCity()
Get cities based on airport code
public
getCity(Request $request) : JsonResponse
Retrieves available cities for a specific airport code. This method supports both creating new records (no ID provided) and editing existing records (ID provided). For existing records, it also returns the current city name.
Parameters
- $request : Request
-
The HTTP request object containing airport information
Tags
Return values
JsonResponse —Returns JSON with cities array and optional current city name
index()
Display a listing of public transportation resources
public
index(Request $request) : View|DataTable
This method handles both AJAX and regular requests for displaying transportation 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, airport name, airport code, and city
- DataTables integration for enhanced user experience
- Action buttons for view, edit, and delete operations
- Case-insensitive search with ILIKE and UPPER functions
- Filter state preservation in action URLs
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 public transportation resource
public
show(int $id, Request $request) : void
Shows detailed information about a specific transportation 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 transportation 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 public transportation resource in storage
public
store(Request $request) : RedirectResponse
Validates and stores a new transportation record with comprehensive features:
- Validates required fields (airport_name)
- Handles image upload with organized directory structure (YYYY/MM)
- Creates thumbnails using Intervention Image library (200x200 with aspect ratio)
- Parses airport information from formatted string
- Processes city names with formatting (handles hyphenated names)
- Creates admin activity log entry
- Supports pricing, route information, and product URLs
Parameters
- $request : Request
-
The HTTP request object containing form data and file uploads
Tags
Return values
RedirectResponse —Redirects to index with success message
update()
Update the specified public transportation resource in storage
public
update(Request $request, int $id) : RedirectResponse
Updates an existing transportation record with validation and security features:
- Validates required fields
- Handles image upload with organized directory structure (YYYY/MM)
- Creates thumbnails using Intervention Image library (200x200 with aspect ratio)
- Parses airport information from formatted string
- Processes city names with formatting (handles hyphenated names)
- Creates admin activity log entry
- Maintains pagination and search filter state
- Supports pricing, route information, and product URLs
- Handles image replacement with cleanup of old files
Parameters
- $request : Request
-
The HTTP request object containing form data and file uploads
- $id : int
-
The ID of the transportation record to update
Tags
Return values
RedirectResponse —Redirects to index with success message and preserved filters