DashboardController
extends Controller
in package
Client dashboard controller.
Manages the client's business dashboard, settings, and site mode controls.
Tags
Table of Contents
Properties
- $layout : string
Methods
- index() : void
- Show the client dashboard.
- resetSidebarOrder() : void
- Reset sidebar order to default.
- saveSidebarOrder() : void
- Save custom sidebar order.
- settings() : void
- Show the business settings form.
- sidebarOrder() : void
- Show the sidebar order management page.
- updateSettings() : void
- Update business settings.
- updateSiteMode() : void
- Update the business site mode.
- zipcodeLookup() : void
- Look up city and state by ZIP code (AJAX endpoint).
- baseUrl() : string
- Get the base URL for the application.
- buildPagination() : array<string|int, mixed>
- Build pagination metadata for views.
- clearOldInput() : void
- Clear stored old input data.
- flash() : void
- Set a flash message in the session.
- flashOldInput() : void
- Store current POST data as old input for form repopulation.
- getPage() : int
- Get the current page number from the query string.
- json() : void
- Send a JSON response.
- old() : mixed
- Get previous form input after validation failure.
- redirect() : void
- Send an HTTP redirect.
- requirePermission() : void
- Require that the authenticated client user has a specific permission.
- url() : string
- Generate a full URL for a given path.
- view() : void
- Render a view template wrapped in a layout.
- deleteBannerFile() : void
- Delete existing banner file for a business.
- deleteLogoFiles() : void
- Delete existing logo and favicon files for a business.
- generateFavicon() : void
- Generate a square favicon PNG from a source image.
- processBannerUpload() : array{success: bool, banner_path?: string, error?: string}
- Process and save a banner image upload.
- processLogoUpload() : array<string|int, mixed>
- Process logo file upload: validate, resize for navbar, generate favicon.
- resizeImage() : void
- Resize an image to fit within max dimensions while maintaining aspect ratio.
Properties
$layout
protected
string
$layout
= 'client'
Layout for client pages
Methods
index()
Show the client dashboard.
public
index() : void
resetSidebarOrder()
Reset sidebar order to default.
public
resetSidebarOrder() : void
saveSidebarOrder()
Save custom sidebar order.
public
saveSidebarOrder() : void
settings()
Show the business settings form.
public
settings() : void
sidebarOrder()
Show the sidebar order management page.
public
sidebarOrder() : void
updateSettings()
Update business settings.
public
updateSettings() : void
updateSiteMode()
Update the business site mode.
public
updateSiteMode() : void
zipcodeLookup()
Look up city and state by ZIP code (AJAX endpoint).
public
zipcodeLookup() : void
baseUrl()
Get the base URL for the application.
protected
baseUrl() : string
Return values
stringbuildPagination()
Build pagination metadata for views.
protected
buildPagination(int $total, int $page, int $perPage, string $baseUrl) : array<string|int, mixed>
Parameters
- $total : int
-
Total record count
- $page : int
-
Current page number
- $perPage : int
-
Records per page
- $baseUrl : string
-
Base URL path (e.g., "client/orders")
Return values
array<string|int, mixed> —Pagination metadata
clearOldInput()
Clear stored old input data.
protected
clearOldInput() : void
flash()
Set a flash message in the session.
protected
flash(string $key, string $message) : void
Parameters
- $key : string
-
Flash message key (e.g., "success", "error")
- $message : string
-
The message text
flashOldInput()
Store current POST data as old input for form repopulation.
protected
flashOldInput() : void
getPage()
Get the current page number from the query string.
protected
getPage() : int
Return values
int —Page number (minimum 1)
json()
Send a JSON response.
protected
json(mixed $data[, int $status = 200 ]) : void
Parameters
- $data : mixed
-
Data to encode as JSON
- $status : int = 200
-
HTTP status code
old()
Get previous form input after validation failure.
protected
old(string $field[, mixed $default = '' ]) : mixed
Parameters
- $field : string
-
The form field name
- $default : mixed = ''
-
Default value if not found
redirect()
Send an HTTP redirect.
protected
redirect(string $url) : void
Parameters
- $url : string
-
The URL to redirect to
requirePermission()
Require that the authenticated client user has a specific permission.
protected
requirePermission(string $permission) : void
Redirects to the client dashboard with an error flash if denied.
Parameters
- $permission : string
-
Permission key (e.g., 'menu_manage')
url()
Generate a full URL for a given path.
protected
url([string $path = '' ]) : string
Parameters
- $path : string = ''
-
The path to append to the base URL
Return values
stringview()
Render a view template wrapped in a layout.
protected
view(string $template[, array<string|int, mixed> $data = [] ]) : void
Parameters
- $template : string
-
Path to view relative to app/Views/ (e.g., "admin/dashboard")
- $data : array<string|int, mixed> = []
-
Variables to extract into the view scope
deleteBannerFile()
Delete existing banner file for a business.
private
deleteBannerFile(array<string|int, mixed> $business) : void
Parameters
- $business : array<string|int, mixed>
-
Business record
deleteLogoFiles()
Delete existing logo and favicon files for a business.
private
deleteLogoFiles(array<string|int, mixed> $business) : void
Parameters
- $business : array<string|int, mixed>
-
Business record
generateFavicon()
Generate a square favicon PNG from a source image.
private
generateFavicon(string $sourcePath, string $destPath[, int $size = 32 ]) : void
Parameters
- $sourcePath : string
-
Path to source image
- $destPath : string
-
Path to output favicon
- $size : int = 32
-
Favicon dimension (default 32)
processBannerUpload()
Process and save a banner image upload.
private
processBannerUpload(array<string|int, mixed> $file, array<string|int, mixed> $business) : array{success: bool, banner_path?: string, error?: string}
Parameters
- $file : array<string|int, mixed>
-
Uploaded file ($_FILES entry)
- $business : array<string|int, mixed>
-
Business record
Return values
array{success: bool, banner_path?: string, error?: string}processLogoUpload()
Process logo file upload: validate, resize for navbar, generate favicon.
private
processLogoUpload(array<string|int, mixed> $file, array<string|int, mixed> $business) : array<string|int, mixed>
Parameters
- $file : array<string|int, mixed>
-
Uploaded file from $_FILES
- $business : array<string|int, mixed>
-
Current business record
Return values
array<string|int, mixed> —Result with success, logo_path, favicon_path, error
resizeImage()
Resize an image to fit within max dimensions while maintaining aspect ratio.
private
resizeImage(string $filePath, int $maxWidth, int $maxHeight) : void
Parameters
- $filePath : string
-
Path to image file (modified in place)
- $maxWidth : int
-
Maximum width
- $maxHeight : int
-
Maximum height