PagesController
extends BaseController
in package
Pages Controller
This controller manages comprehensive page operations including page CRUD, image/video/document uploads, CKEditor integration, DataTables integration, custom fields management, taxonomy handling, and page alias generation. It provides functionality for managing dynamic pages with advanced content management capabilities including media handling and SEO optimization.
Table of Contents
Methods
- __construct() : void
- Create a new PagesController instance.
- basicPageInfo() : array<string|int, mixed>
- Prepare basic page information from request data.
- create() : View
- Show the form for creating a new page.
- deleteDocument() : void
- Delete page document and update database record.
- deleteImage() : void
- Delete page image and update database record.
- deleteVideo() : void
- Delete page video and update database record.
- destroy() : mixed
- downloadResume() : RedirectResponse|void
- Download page document with custom filename.
- edit() : View
- Show the form for editing the specified resource.
- editPageALias() : void
- Update page alias via AJAX request.
- imageUploadOnpage() : void
- Handle image uploads for page content.
- imageUploadOnpageCkeditor() : void
- Handle image uploads for CKEditor integration.
- index() : View|JsonResponse
- Display a listing of pages with DataTables integration and advanced filtering.
- otherPageInfo() : array<string|int, mixed>
- Add media file information to page data array.
- PageAliasCreator() : string
- Create unique page aliases for SEO-friendly URLs.
- RecursiveAliaseCreator() : string
- Recursively create unique page aliases by appending counter if duplicate exists.
- show() : View
- Show the form for creating a new resource.
- store() : RedirectResponse
- Store a newly created page in storage.
- update() : RedirectResponse
- Update the specified resource in storage.
- uploadDoc() : string
- Upload and process document files for page content.
- uploadImage() : string
- Upload and process images for page content.
- uploadVideo() : string
- Upload and process video files for page content.
Methods
__construct()
Create a new PagesController instance.
public
__construct() : void
Checks if user is logged in and has proper permissions for page management. Validates HTTPS protocol and redirects to appropriate page if permissions are not met.
basicPageInfo()
Prepare basic page information from request data.
public
basicPageInfo(Request $request, string $pcmSlug) : array<string|int, mixed>
Extracts and processes basic page information from the request including title, description, meta data, video information, and other page properties. Handles video type logic and session-based user identification.
Parameters
- $request : Request
- $pcmSlug : string
-
Page category module slug
Return values
array<string|int, mixed> —Array of basic page information
create()
Show the form for creating a new page.
public
create(Request $request) : View
Displays the page creation form with initialized form fields and related data. Loads page categories, taxonomy, custom fields, and parent pages for form population. Provides interface for adding new pages with comprehensive content management options.
Parameters
- $request : Request
Return values
ViewdeleteDocument()
Delete page document and update database record.
public
deleteDocument(int $id) : void
Removes document file from server storage and clears document-related fields in the database. Handles file deletion with proper error handling and database record updates.
Parameters
- $id : int
-
Page ID
deleteImage()
Delete page image and update database record.
public
deleteImage(int $id) : void
Removes image file and thumbnail from server storage and clears image-related fields in the database. Handles both main image and thumbnail deletion with proper error handling.
Parameters
- $id : int
-
Page ID
deleteVideo()
Delete page video and update database record.
public
deleteVideo(int $id) : void
Removes video file from server storage and clears video-related fields in the database. Handles video file deletion with proper error handling and database record updates.
Parameters
- $id : int
-
Page ID
destroy()
public
destroy(mixed $id, Request $request) : mixed
Parameters
- $id : mixed
- $request : Request
downloadResume()
Download page document with custom filename.
public
downloadResume(Request $request) : RedirectResponse|void
Handles document downloads with security validation and custom filename generation. Validates request parameters and generates SEO-friendly filenames based on page alias. Sets appropriate headers for file download with proper content type handling.
Parameters
- $request : Request
Return values
RedirectResponse|voidedit()
Show the form for editing the specified resource.
public
edit(Request $request, mixed $id) : View
Parameters
- $request : Request
- $id : mixed
Return values
VieweditPageALias()
Update page alias via AJAX request.
public
editPageALias(Request $request, int $id) : void
Handles AJAX requests to update page aliases with uniqueness validation. Creates new unique alias using PageAliasCreator and updates the database. Returns JSON response with success status and updated alias.
Parameters
- $request : Request
- $id : int
-
Page ID
imageUploadOnpage()
Handle image uploads for page content.
public
imageUploadOnpage() : void
Processes image uploads for page content with CORS support and security validation. Validates file types and moves uploaded files to webimages directory. Returns JSON response with file location for content integration.
imageUploadOnpageCkeditor()
Handle image uploads for CKEditor integration.
public
imageUploadOnpageCkeditor() : void
Processes image uploads from CKEditor with CORS support and security validation. Validates file types, creates year/month folder structure, and returns JSON response for CKEditor integration. Supports multiple file formats including images and documents.
index()
Display a listing of pages with DataTables integration and advanced filtering.
public
index(Request $request) : View|JsonResponse
Provides a paginated list of pages with comprehensive search capabilities. Supports filtering by page title, alias, and status with DataTables integration. Displays pages with action buttons for view, edit, and delete operations.
Parameters
- $request : Request
Return values
View|JsonResponseotherPageInfo()
Add media file information to page data array.
public
otherPageInfo(array<string|int, mixed> $pageInfo, string $imagePath, string $uploadedFile, string $videoUploadedFile, string $uploadedDoc) : array<string|int, mixed>
Merges uploaded media file information (images, videos, documents) into the page information array for database storage. Handles file paths and names for all media types associated with the page.
Parameters
- $pageInfo : array<string|int, mixed>
-
Basic page information array
- $imagePath : string
-
Image file path
- $uploadedFile : string
-
Uploaded image filename
- $videoUploadedFile : string
-
Uploaded video filename
- $uploadedDoc : string
-
Uploaded document filename
Return values
array<string|int, mixed> —Page information with media file data
PageAliasCreator()
Create unique page aliases for SEO-friendly URLs.
public
PageAliasCreator(Page $pageModel, string $pageName, int $navmenu_id) : string
Generates URL-friendly aliases from page titles by converting to lowercase, replacing spaces with hyphens, and ensuring uniqueness through recursive checking. Used for creating SEO-optimized page URLs.
Parameters
- $pageModel : Page
-
Page model instance
- $pageName : string
-
Original page title
- $navmenu_id : int
-
Navigation menu ID
Return values
string —Generated unique page alias
RecursiveAliaseCreator()
Recursively create unique page aliases by appending counter if duplicate exists.
public
RecursiveAliaseCreator(string $pageAlias, int $counter) : string
Checks if a page alias already exists in the database and appends a counter to make it unique. Recursively calls itself until a unique alias is found. Used internally by PageAliasCreator for ensuring alias uniqueness.
Parameters
- $pageAlias : string
-
Current page alias to check
- $counter : int
-
Counter to append for uniqueness
Return values
string —Unique page alias
show()
Show the form for creating a new resource.
public
show(mixed $id, Request $request) : View
Parameters
- $id : mixed
- $request : Request
Return values
Viewstore()
Store a newly created page in storage.
public
store(Request $request) : RedirectResponse
Validates page data and creates a new page record with comprehensive content management. Handles image, video, and document uploads, custom fields, taxonomy, and page alias generation. Provides appropriate feedback message after successful creation.
Parameters
- $request : Request
Return values
RedirectResponseupdate()
Update the specified resource in storage.
public
update(Request $request) : RedirectResponse
Parameters
- $request : Request
Return values
RedirectResponseuploadDoc()
Upload and process document files for page content.
public
uploadDoc(Request $request, string $method, string $extra[, string $uploadedDoc = '' ]) : string
Handles document file uploads with validation and file management for page content. Supports multiple document formats (PDF, DOC, DOCX, CSV, XLS, PPT) and manages file cleanup for updates. Returns filename for database storage.
Parameters
- $request : Request
- $method : string
-
'insert' or 'update'
- $extra : string
-
Additional suffix for filename
- $uploadedDoc : string = ''
-
Existing filename for updates
Return values
string —Uploaded document filename
uploadImage()
Upload and process images for page content.
public
uploadImage(Request $request, string $method[, string $extra = '' ][, string $uploadedFile = '' ]) : string
Handles image file uploads with validation, thumbnail generation, and file management. Supports multiple image formats (JPEG, JPG, PNG, GIF) and creates thumbnails automatically. Manages file cleanup for updates and returns file information for database storage.
Parameters
- $request : Request
- $method : string
-
'insert' or 'update'
- $extra : string = ''
-
Additional suffix for filename
- $uploadedFile : string = ''
-
Existing filename for updates
Return values
string —File information string (filename##path)
uploadVideo()
Upload and process video files for page content.
public
uploadVideo(Request $request, string $method[, string $extra = '' ], string $videoType[, string $videoUploadedFile = '' ]) : string
Handles video file uploads with validation and file management for page content. Supports MP4 format and manages file cleanup for updates. Returns filename for database storage.
Parameters
- $request : Request
- $method : string
-
'insert' or 'update'
- $extra : string = ''
-
Additional suffix for filename
- $videoType : string
-
Type of video (upload/youtube)
- $videoUploadedFile : string = ''
-
Existing filename for updates
Return values
string —Uploaded video filename