ClientAuthController
extends Controller
in package
Client authentication controller.
Handles registration, login, and logout for restaurant/business owners.
Tags
Table of Contents
Properties
- $layout : string
Methods
- login() : void
- Process client login.
- loginForm() : void
- Show the client login form.
- logout() : void
- Log out the client.
- register() : void
- Process client registration — validates input, stores pending data in session, sends a 6-digit verification code, and redirects to the verify-email page.
- registerForm() : void
- Show the client registration form.
- resendCode() : void
- Regenerate the OTP, re-send the verification email, and redirect back to the verify-email form.
- verify() : void
- Verify the submitted code against the session OTP and create the business + user account on success.
- verifyForm() : void
- Show the email verification code entry form.
- 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.
- maskEmail() : string
- Mask an email address for display (e.g., j***n@gmail.com).
- validateRegistration() : array<string|int, mixed>
- Validate registration form input.
Properties
$layout
protected
string
$layout
= 'main'
Layout for client auth pages
Methods
login()
Process client login.
public
login() : void
loginForm()
Show the client login form.
public
loginForm() : void
logout()
Log out the client.
public
logout() : void
register()
Process client registration — validates input, stores pending data in session, sends a 6-digit verification code, and redirects to the verify-email page.
public
register() : void
registerForm()
Show the client registration form.
public
registerForm() : void
resendCode()
Regenerate the OTP, re-send the verification email, and redirect back to the verify-email form.
public
resendCode() : void
verify()
Verify the submitted code against the session OTP and create the business + user account on success.
public
verify() : void
verifyForm()
Show the email verification code entry form.
public
verifyForm() : void
Redirects to the registration page if there is no pending registration in the session.
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
maskEmail()
Mask an email address for display (e.g., j***n@gmail.com).
private
maskEmail(string $email) : string
Parameters
- $email : string
-
Full email address
Return values
string —Masked email
validateRegistration()
Validate registration form input.
private
validateRegistration() : array<string|int, mixed>
Return values
array<string|int, mixed> —List of error messages