SiteModeMiddleware
extends Middleware
in package
Site mode middleware for storefront access control.
Controls visibility based on business site_status, scheduled maintenance windows, and platform-wide maintenance mode. Supports four maintenance levels with different access tiers.
Tags
Table of Contents
Methods
- handle() : bool
- Handle the request by checking maintenance and site status.
- checkPlatformMaintenance() : array<string|int, mixed>|null
- Check platform-wide maintenance mode (from platform_settings table).
- detectRole() : string|null
- Detect the current user's role relative to the given business.
- renderMaintenance() : void
- Render the maintenance page with 503 status.
- setUpcomingNotice() : void
- Set upcoming maintenance notice for banner display.
Methods
handle()
Handle the request by checking maintenance and site status.
public
handle([array<string|int, mixed> $params = [] ]) : bool
Parameters
- $params : array<string|int, mixed> = []
-
Route parameters (expects 'slug')
Return values
boolcheckPlatformMaintenance()
Check platform-wide maintenance mode (from platform_settings table).
private
checkPlatformMaintenance(string|null $role) : array<string|int, mixed>|null
Parameters
- $role : string|null
-
Current user role
Return values
array<string|int, mixed>|null —Blocking info or null if access is allowed
detectRole()
Detect the current user's role relative to the given business.
private
detectRole(array<string|int, mixed> $business) : string|null
Parameters
- $business : array<string|int, mixed>
-
Business record
Return values
string|null —Role name or null for unauthenticated
renderMaintenance()
Render the maintenance page with 503 status.
private
renderMaintenance(string|null $message, string|null $reason) : void
Parameters
- $message : string|null
-
Custom message
- $reason : string|null
-
Maintenance reason
setUpcomingNotice()
Set upcoming maintenance notice for banner display.
private
setUpcomingNotice(MaintenanceWindow $mwModel, int $businessId) : void
Parameters
- $mwModel : MaintenanceWindow
-
Maintenance window model
- $businessId : int
-
Business ID