Airport Guide Documentation

ShuttleServicesController extends BaseController
in package

Shuttle Services Management Controller

This controller handles all operations related to shuttle service rates and details management. It provides CRUD operations for managing shuttle service companies, their pricing, contact information, vehicle types, transportation options, and associated airport data. The controller includes features for listing, creating, editing, viewing, and deleting shuttle service records with proper validation, image processing, and admin activity logging.

Features:

  • DataTables integration with advanced search and filtering
  • Image upload and processing with organized directory structure
  • Airport code parsing and validation
  • Security validation with MD5 hash verification
  • Admin activity logging for all operations
  • Vehicle type and transportation type management
  • Pricing and currency handling
  • City name formatting and processing
Tags
author

Airport Guide System

version
1.0
since
2024

Table of Contents

Methods

__construct()  : void
Constructor for ShuttleServicesController
create()  : View
Show the form for creating a new shuttle service resource
deleteImage()  : void
Delete image for a specific shuttle service record
destroy()  : RedirectResponse
Remove the specified shuttle service resource from storage
edit()  : View|RedirectResponse
Show the form for editing the specified shuttle service resource
getCity()  : JsonResponse
Get cities for a specific airport code
index()  : View|DataTable
Display a listing of shuttle service resources
show()  : void
Display the specified shuttle service resource
store()  : RedirectResponse
Store a newly created shuttle service resource in storage
update()  : RedirectResponse
Update the specified shuttle service resource in storage

Methods

__construct()

Constructor for ShuttleServicesController

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 shuttle service resource

public create(Request $request) : View

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

Parameters
$request : Request

The HTTP request object

Tags
example

GET /admin/shuttleservice/create

Return values
View

Returns the create form view

deleteImage()

Delete image for a specific shuttle service record

public deleteImage(int $id) : void

Removes the associated image file and thumbnail for a shuttle service record. Updates the database to clear the image references.

Parameters
$id : int

The ID of the shuttle service record

Tags
example

GET /admin/shuttleservice/delete-image/123

Return values
void

Outputs "true" on success or "false" on failure

destroy()

Remove the specified shuttle service resource from storage

public destroy(int $id) : RedirectResponse

Deletes a shuttle service record and associated image files from storage. Performs cleanup of both original images and thumbnails. Creates admin activity log entry for the deletion.

Features:

  • File cleanup (original and thumbnail images)
  • Admin activity logging
  • Soft/hard delete handling
Parameters
$id : int

The ID of the shuttle service record to delete

Tags
example

DELETE /admin/shuttleservice/123

Return values
RedirectResponse

Redirects to index with success message

edit()

Show the form for editing the specified shuttle service resource

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

Displays the edit form for an existing shuttle 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 shuttle service record to edit

$request : Request

The HTTP request object containing security key and pagination data

Tags
example

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

Return values
View|RedirectResponse

Returns edit form or redirects on security failure

getCity()

Get cities for a specific airport code

public getCity(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/shuttleservice/get-city?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 shuttle service resources

public index(Request $request) : View|DataTable

This method handles both AJAX and regular requests for displaying shuttle 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 title, state, city, 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
  • City name formatting for display
Parameters
$request : Request

The HTTP request object containing search parameters and pagination data

Tags
example

// Regular request GET /admin/shuttleservice

// AJAX request with search filters GET /admin/shuttleservice?ajax=1&company_title=ABC&airport_code=JFK&city=New York

Return values
View|DataTable

Returns view for regular requests or DataTable for AJAX

show()

Display the specified shuttle service resource

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

Shows detailed information about a specific shuttle 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 shuttle service record to display

$request : Request

The HTTP request object

Tags
example

GET /admin/shuttleservice/123

Output:

Airport NameJohn F. Kennedy International Airport
Company NameABC Shuttle Services
Price25.00 USD
Return values
void

Outputs HTML content directly to the response

store()

Store a newly created shuttle service resource in storage

public store(Request $request) : RedirectResponse

Validates and stores a new shuttle service record with comprehensive features:

  • Validates required fields (airport_name)
  • Parses airport information from formatted string
  • Handles image upload with organized directory structure (YYYY/MM)
  • Creates thumbnails using Intervention Image library
  • Processes city names with formatting
  • Manages vehicle types and transportation types
  • Creates admin activity log entry
Parameters
$request : Request

The HTTP request object containing form data and file uploads

Tags
throws
ValidationException

When validation fails

example

POST /admin/shuttleservice

Request data: { "airport_name": "John F. Kennedy International Airport (JFK)", "company_title": "ABC Shuttle Services", "company_url": "https://abcshuttle.com", "company_phone1": "+1-555-123-4567", "company_address": "123 Main St, New York, NY", "city": "new-york", "state": "NY", "zip_code": "10001", "price": "25.00", "currency": "USD", "per_group": "per person", "car_type": ["sedan", "van"], "transportation_type": ["shuttle", "scheduled_service"], "file": [image file] }

Return values
RedirectResponse

Redirects to index with success message

update()

Update the specified shuttle service resource in storage

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

Updates an existing shuttle service record with comprehensive features:

  • Validates required fields
  • Parses airport information from formatted string
  • Handles image replacement with old file cleanup
  • Creates thumbnails using Intervention Image library
  • Manages vehicle types and transportation types with proper state management
  • Creates admin activity log entry
  • Maintains pagination and search filter state
Parameters
$request : Request

The HTTP request object containing form data and file uploads

$id : int

The ID of the shuttle service record to update

Tags
throws
ValidationException

When validation fails

example

PUT /admin/shuttleservice/123

Request data: { "airport_name": "John F. Kennedy International Airport (JFK)", "company_title": "Updated ABC Shuttle Services", "company_url": "https://updated.abcshuttle.com", "company_phone1": "+1-555-987-6543", "city": "new-york", "state": "NY", "price": "30.00", "currency": "USD", "car_type": ["sedan", "suv"], "transportation_type": ["shuttle"], "old_shuttleservice_pic": "old_image.jpg", "file": [new image file] }

Return values
RedirectResponse

Redirects to index with success message and preserved filters


        
On this page

Search results