ViatorController
extends BaseController
in package
Viator Tour and Activity Management Controller
This controller handles all operations related to Viator tour and activity management. It provides CRUD operations for managing Viator products, including tours, activities, and transportation services. The controller includes features for listing, creating, editing, viewing, and deleting Viator records with proper validation, image URL management, car type selection, 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/Hide)
- Car type selection (sedan, van, suv, bus, stretched_limo, misc)
- Image URL management for different vehicle types
- Pricing and destination information handling
- Product code and destination ID management
Tags
Table of Contents
Methods
- __construct() : void
- Constructor for ViatorController
- create() : View
- Show the form for creating a new Viator tour/activity resource
- destroy() : RedirectResponse
- Remove the specified Viator tour/activity resource from storage
- edit() : View|RedirectResponse
- Show the form for editing the specified Viator tour/activity resource
- index() : View|DataTable
- Display a listing of Viator tour and activity resources
- show() : void
- Display the specified Viator tour/activity resource
- store() : RedirectResponse
- Store a newly created Viator tour/activity resource in storage
- update() : RedirectResponse
- Update the specified Viator tour/activity resource in storage
Methods
__construct()
Constructor for ViatorController
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 Viator tour/activity resource
public
create(Request $request) : View
Displays the create form with necessary data for adding a new Viator product. 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 Viator tour/activity resource from storage
public
destroy(int $id) : RedirectResponse
Deletes a Viator 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 Viator record to delete
Tags
Return values
RedirectResponse —Redirects to index with success message
edit()
Show the form for editing the specified Viator tour/activity resource
public
edit(int $id, Request $request) : View|RedirectResponse
Displays the edit form for an existing Viator 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 Viator 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 Viator tour and activity resources
public
index(Request $request) : View|DataTable
This method handles both AJAX and regular requests for displaying Viator 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 city, state, title, and airport code
- DataTables integration for enhanced user experience
- Action buttons for view, edit, and delete operations
- Case-insensitive search with ILIKE and UPPER functions
- Status column display (Active/Hide)
- Combined city and state display
- 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 Viator tour/activity resource
public
show(int $id, Request $request) : void
Shows detailed information about a specific Viator 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 Viator record to display
- $request : Request
-
The HTTP request object
Return values
void —Outputs HTML content directly to the response
store()
Store a newly created Viator tour/activity resource in storage
public
store(Request $request) : RedirectResponse
Validates and stores a new Viator record with comprehensive features:
- Validates required fields (airport_name)
- Parses airport information from formatted string
- Creates admin activity log entry
- Handles car type selection (sedan, van, suv, bus, stretched_limo, misc)
- Manages image URLs for different vehicle types
- Supports pricing, destination information, and product URLs
- Handles product codes and destination IDs
Parameters
- $request : Request
-
The HTTP request object containing form data
Tags
Return values
RedirectResponse —Redirects to index with success message
update()
Update the specified Viator tour/activity resource in storage
public
update(Request $request, int $id) : RedirectResponse
Updates an existing Viator 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 car type selection with proper state management
- Manages status changes (Active/Hide) with hide reason
- Supports pricing, destination information, and product URLs
- Handles image URLs for different vehicle types
Parameters
- $request : Request
-
The HTTP request object containing form data
- $id : int
-
The ID of the Viator record to update
Tags
Return values
RedirectResponse —Redirects to index with success message and preserved filters