Airport Guide Documentation

TopicController extends BaseController
in package

Topic Management Controller

This controller handles all operations related to topic management in the CMS. It provides CRUD operations for managing topics with proper validation and admin activity logging. The controller includes features for listing, creating, editing, and deleting topic records.

Features:

  • Pagination support with configurable page size
  • Search functionality with case-insensitive filtering
  • Sortable results
  • Security validation with MD5 hash verification
  • Session management
  • Simple topic name management
Tags
author

Airport Guide System

version
1.0
since
2024

Table of Contents

Methods

__construct()  : void
Constructor for TopicController
create()  : View
Show the form for creating a new topic resource
destroy()  : RedirectResponse
Remove the specified topic resource from storage
edit()  : View|RedirectResponse
Show the form for editing the specified topic resource
index()  : View
Display a listing of topic resources
store()  : RedirectResponse
Store a newly created topic resource in storage
update()  : RedirectResponse
Update the specified topic resource in storage

Methods

__construct()

Constructor for TopicController

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 topic resource

public create(Request $request) : View

Displays the create form for adding a new topic to the CMS. Prepares an empty Topic model instance for the form.

Parameters
$request : Request

The HTTP request object

Tags
example

GET /admin/topic/create

Return values
View

Returns the create form view

destroy()

Remove the specified topic resource from storage

public destroy(int $id) : RedirectResponse

Deletes a topic record from the database. Performs soft delete if the model supports it, otherwise performs hard delete.

Parameters
$id : int

The ID of the topic record to delete

Tags
example

DELETE /admin/topic/123

Return values
RedirectResponse

Redirects to index with success message

edit()

Show the form for editing the specified topic resource

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

Displays the edit form for an existing topic record with security validation. Includes MD5 hash verification to prevent unauthorized access.

Parameters
$id : int

The ID of the topic record to edit

$request : Request

The HTTP request object containing security key

Tags
example

GET /admin/topic/123/edit?key=abc123

Return values
View|RedirectResponse

Returns edit form or redirects on security failure

index()

Display a listing of topic resources

public index(Request $request) : View

This method handles the display of all topic records with search functionality. Provides pagination support and search filtering by topic name.

Features:

  • Pagination with configurable page size
  • Search functionality by topic name (case-insensitive)
  • Sortable results
  • Session management
Parameters
$request : Request

The HTTP request object containing search parameters

Tags
example

// Regular request GET /admin/topic

// Request with search GET /admin/topic?search=airport

Return values
View

Returns the topic listing view

store()

Store a newly created topic resource in storage

public store(Request $request) : RedirectResponse

Validates and stores a new topic record with the following features:

  • Validates required fields (topic_name)
  • Creates admin activity tracking
  • Simple topic name management
Parameters
$request : Request

The HTTP request object containing form data

Tags
throws
ValidationException

When validation fails

example

POST /admin/topic

Request data: { "topic_name": "Airport Transportation" }

Return values
RedirectResponse

Redirects to index with success message

update()

Update the specified topic resource in storage

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

Updates an existing topic record with validation and security features:

  • Validates required fields
  • Updates admin tracking information
  • Simple topic name management
Parameters
$request : Request

The HTTP request object containing form data

$id : int

The ID of the topic record to update

Tags
throws
ValidationException

When validation fails

example

PUT /admin/topic/123

Request data: { "topic_name": "Updated Airport Transportation" }

Return values
RedirectResponse

Redirects to index with success message


        
On this page

Search results