Airport Guide Documentation

TerminalController extends BaseController
in package

Terminal Management Controller

This controller handles all operations related to airport terminal management. It provides CRUD operations for managing terminal details, terminal images, terminal options, and associated airport data. The controller includes features for listing, creating, editing, viewing, and deleting terminal 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
  • Terminal type management (terminal, concourse, gates)
  • Terminal alias generation and slug management
  • Map image handling (2D and 3D)
  • Terminal level management with printable and interactive maps
  • Security validation with MD5 hash verification
  • Admin activity logging for all operations
  • Drag and drop sorting for terminal levels
  • File management with automatic cleanup
Tags
author

Airport Guide System

version
1.0
since
2024

Table of Contents

Methods

__construct()  : void
Constructor for TerminalController
changeImageLevel()  : bool
Change terminal level name and update associated files
changeLevelText()  : bool
Change terminal level text description
create()  : View
Show the form for creating a new terminal resource
deleteImage()  : void
Delete terminal level image
deleteMapImage()  : void
Delete terminal map images (2D or 3D)
destroy()  : RedirectResponse
Remove the specified terminal resource from storage
edit()  : View|RedirectResponse
Show the form for editing the specified terminal resource
index()  : View|DataTable
Display a listing of terminal resources
saveLevelData()  : bool
Save terminal level data (name and text) in one operation
show()  : void
Display the specified terminal resource
sorting()  : void
Sort terminal level images via drag and drop
store()  : RedirectResponse
Store a newly created terminal resource in storage
terminalImage()  : View|RedirectResponse
Show terminal level management interface
update()  : RedirectResponse
Update the specified terminal resource in storage
upload()  : JsonResponse
Upload image for terminal content
UploadImageToServer()  : void
Upload and process terminal level images

Methods

__construct()

Constructor for TerminalController

public __construct() : void

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

changeImageLevel()

Change terminal level name and update associated files

public changeImageLevel(Request $request, int $id) : bool

Updates the level name and renames associated image files (both printable and 3D images) to maintain consistency. Handles file system operations for both main images and preview thumbnails.

Parameters
$request : Request

The HTTP request object containing new level name

$id : int

The ID of the terminal image record

Tags
example

POST /admin/terminal/change-image-level/123

Request data: { "gphoto_title": "Level 2", "img_id": "123" }

Return values
bool

Returns true on success, false on failure

changeLevelText()

Change terminal level text description

public changeLevelText(Request $request, int $id) : bool

Updates the level text description for a terminal image record.

Parameters
$request : Request

The HTTP request object containing new level text

$id : int

The ID of the terminal image record

Tags
example

POST /admin/terminal/change-level-text/123

Request data: { "level_text": "Updated level description", "img_id": "123" }

Return values
bool

Returns true on success, false on failure

create()

Show the form for creating a new terminal resource

public create(Request $request) : View

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

Parameters
$request : Request

The HTTP request object

Tags
example

GET /admin/terminal/create

Return values
View

Returns the create form view

deleteImage()

Delete terminal level image

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

Deletes a terminal level image record and removes associated files from storage. Handles cleanup of both main images and preview thumbnails for both printable and 3D images.

Parameters
$request : Request

The HTTP request object containing form type

$id : int

The ID of the terminal image record to delete

Tags
example

POST /admin/terminal/delete-image/123

Request data: { "form_type": "add_terminal_photo" }

Return values
void

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

deleteMapImage()

Delete terminal map images (2D or 3D)

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

Deletes either 2D or 3D map images for a terminal record and removes associated files from storage. Handles cleanup of both main images and preview thumbnails.

Parameters
$id : int

The ID of the terminal record

$request : Request

The HTTP request object containing image type

Tags
example

POST /admin/terminal/delete-map-image/123

Request data: { "imageType": "2D" // or "3D" }

Response: true // or false

Return values
void

Outputs JSON response with success/failure status

destroy()

Remove the specified terminal resource from storage

public destroy(int $id) : RedirectResponse

Deletes a terminal 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 terminal record to delete

Tags
example

DELETE /admin/terminal/123

Return values
RedirectResponse

Redirects to index with success message

edit()

Show the form for editing the specified terminal resource

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

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

$request : Request

The HTTP request object containing security key and pagination data

Tags
example

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

Return values
View|RedirectResponse

Returns edit form or redirects on security failure

index()

Display a listing of terminal resources

public index(Request $request) : View|DataTable

This method handles both AJAX and regular requests for displaying terminal 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 terminal name, airport name, and airport code
  • DataTables integration for enhanced user experience
  • Action buttons for view, edit, and level management
  • Case-insensitive search with ILIKE functions
  • Role-based delete permissions (super admin only)
Parameters
$request : Request

The HTTP request object containing search parameters and pagination data

Tags
example

// Regular request GET /admin/terminal

// AJAX request with search filters GET /admin/terminal?ajax=1&terminal_name=Terminal&airport_code=JFK

Return values
View|DataTable

Returns view for regular requests or DataTable for AJAX

saveLevelData()

Save terminal level data (name and text) in one operation

public saveLevelData(Request $request, int $id) : bool

Updates both the level name and level text for a terminal image record. Also renames associated image files to maintain consistency with the new level name. Handles file system operations for both main images and preview thumbnails.

Parameters
$request : Request

The HTTP request object containing level name and text

$id : int

The ID of the terminal image record

Tags
example

POST /admin/terminal/save-level-data/123

Request data: { "gphoto_title": "Level 3", "level_text": "Updated level description", "img_id": "123" }

Return values
bool

Returns true on success, false on failure

show()

Display the specified terminal resource

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

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

$request : Request

The HTTP request object

Tags
example

GET /admin/terminal/123

Output:

Airport NameJohn F. Kennedy International Airport
Terminal NameTerminal 1
Terminal DescriptionMain terminal building
Return values
void

Outputs HTML content directly to the response

sorting()

Sort terminal level images via drag and drop

public sorting(Request $request) : void

Handles the reordering of terminal level images based on drag and drop operations. Updates the sort_by field for all affected images.

Parameters
$request : Request

The HTTP request object containing sortable data

Tags
example

POST /admin/terminal/sorting

Request data: { "sortable": "dltImg_123", "dltImg": ["123", "456", "789"] }

Response: {"status": "success"}

Return values
void

Outputs JSON response with status

store()

Store a newly created terminal resource in storage

public store(Request $request) : RedirectResponse

Validates and stores a new terminal record with comprehensive features:

  • Validates required fields (airport_name, terminal_slug, terminal_type)
  • Parses airport information from formatted string
  • Generates terminal aliases based on type (terminal, concourse, gates)
  • Handles map image uploads (2D and 3D) with organized directory structure
  • Creates thumbnails using Intervention Image library
  • Manages terminal sorting and alias generation
  • 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/terminal

Request data: { "airport_name": "John F. Kennedy International Airport (JFK)", "terminal_slug": "Terminal 1", "terminal_type": "terminal", "terminal_name": "Terminal 1", "terminal_desc": "Main terminal building", "map_img": [image file], "3d_map_img": [image file], "over_title": "Overview", "over_desc": "Terminal overview description" }

Return values
RedirectResponse

Redirects to index with success message

terminalImage()

Show terminal level management interface

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

Displays the terminal level management interface for managing terminal images, levels, and interactive maps. Includes security validation with MD5 hash verification.

Parameters
$id : int

The ID of the terminal record

$request : Request

The HTTP request object containing security key and pagination data

Tags
example

GET /admin/terminal/123/img-terminal?key=abc123&page_no=2

Return values
View|RedirectResponse

Returns level management view or redirects on security failure

update()

Update the specified terminal resource in storage

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

Updates an existing terminal record with comprehensive features:

  • Validates required fields
  • Parses airport information from formatted string
  • Handles map image replacement with old file cleanup
  • Creates thumbnails using Intervention Image library
  • Manages terminal aliases and type changes
  • 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 terminal record to update

Tags
throws
ValidationException

When validation fails

example

PUT /admin/terminal/123

Request data: { "airport_name": "John F. Kennedy International Airport (JFK)", "terminal_slug": "Updated Terminal 1", "terminal_type": "terminal", "terminal_name": "Updated Terminal 1", "terminal_desc": "Updated terminal description", "old_map_img": "old_image.jpg", "map_img": [new image file], "old_3d_img": "old_3d_image.jpg", "3d_map_img": [new 3D image file] }

Return values
RedirectResponse

Redirects to index with success message and preserved filters

upload()

Upload image for terminal content

public upload(Request $request) : JsonResponse

Handles image uploads for terminal content management, typically used with rich text editors. Supports various image formats and stores them in the public uploads directory.

Parameters
$request : Request

The HTTP request object containing the image file

Tags
example

POST /admin/terminal/upload

Response: { "fileName": "image_1234567890.jpg", "uploaded": 1, "url": "http://example.com/uploads/terminal/image_1234567890.jpg" }

Return values
JsonResponse

Returns JSON response with file information

UploadImageToServer()

Upload and process terminal level images

public UploadImageToServer(Request $request) : void

Handles the upload and processing of terminal level images including:

  • Printable level images
  • 3D interactive map images
  • Automatic file naming and organization
  • Thumbnail generation
  • Database record creation

Supports multiple form types:

  • add_terminal_photo: Creates new level with printable image
  • add_3d_photo: Adds 3D image to existing level
  • add_printable_photo: Updates printable image for existing level
Parameters
$request : Request

The HTTP request object containing image file and form data

Tags
example

POST /admin/terminal/upload-image-to-server

Request data: { "img_file": [image file], "form_type": "add_terminal_photo", "gid": "123", "locid": "JFK" }

Return values
void

Outputs HTML content for image management interface


        
On this page

Search results