class Module extends Crud implements IAuth

Constants

ACTION_PREFIX

Action methods prefix

INFINITY

Constant. Infinite number of results requested.

ASC

Constant. Ascending order.

DESC

Constant. Descending order.

Properties

public $defaultRequest Default crud request from Crud
protected $title
protected $icon
protected $views Add views directory to module; from Module
protected $roles
protected $actionRoles override to set authorized roles from Module
protected $crudColumns from Crud
protected $crudActions Actions chainset class from Crud
protected $crudFilters Filters chainset class from Crud
protected $model
protected $possibleRoles List of possible roles in format [ => , .

Public Methods

__construct($core, $elakey)

Each module has to be initialized with eladmin instance and its own elakey.

from Module
final
core()

Return core instance

from Module
final
string
elakey()

Each module has its elakey - index in modules array - used to address requests.

from Module
final
bool
auth(string|null $action = null)

Check if user is authorized to do action, or athorized to access module at all.

from Module
string
title()

Get name of the module.

string
icon()

Get icon of the module.

from Module
final
string
requestUrl(string|null $action = null, array $args = [])

Return url for this module.

from Module
final
string
assetUrl(string $path, string|null $version = null)

Create asset url, file path relative to /assets directory. Default $version = time()

from Module
void
prepare()

Runs before any action is executed.

from Crud
final
array|null
roles(string|null $action = null)

Get roles authorized to work with the module, or specific action. Empty array means any role is authorized.

from Module
final
string
render(string $template, array $args = [])

Return rendered view.

from Module
void
renderAsset(string $path)

Determinate asset content-type and render it.

from Module
bool
implementsSoftDeletes()

IMPLEMENT. Does CRUD use soft deletes?

from Crud
bool
implementsSearch()

IMPLEMENT. Does CRUD support searching?

from Crud
bool
implementsPaging()

IMPLEMENT. Does CRUD support paging?

from Crud
bool
implementsSorting()

IMPLEMENT. Does CRUD support sorting?

from Crud
bool
implementsFilters()

IMPLEMENT. Does CRUD support filtering?

from Crud
string
primary()

IMPLEMENT. Name of primary key column. Default is 'id'.

from Crud
final
getCrudColumns()

Get columns chainset.

from Crud
final
getCrudActions()

Get actions chainset.

from Crud
final
getCrudFilters()

Get filters chainset.

from Crud
actionCreateForm()

ACTION. Show form - create entry.

from Crud
actionUpdateForm()

ACTION. Show form - edit entry.

from Crud
actionRead()

ACTION. List database entries.

from Crud
actionUpdate()

ACTION. Edit database entry.

from Crud
actionCreate()

ACTION. Create database entry.

from Crud
actionDelete()

ACTION. Hard delete.

actionSoftDelete()

ACTION. Soft delete.

from Crud
actionRestore()

ACTION. Restore.

from Crud
array|null
loginFields()

Return an array of login fields in the form of field_name=>[label=>input label, type=>input_type] Retrurn null if Eladmin login dialog should be disabled (and you want to do authentication on your own)

void
unauthorized()

This method is called when user is not autorized and loginFileds returns null.

user()

No description

void
login(array $fields)

Eladmin calls this method during authentication.

void
logout()

Logout.

bool
authorize(array $authorizedRoles = self::ANYONE)

Check if user is logged in. Also check if user has one of the $authorizedRoles (if specified).

void
accountUpdate($fields)

Eladmin calls this method during profile update.

string
userName()

Get user's name to show it in admin.

array|null
accountFields()

Return an array of profile fields in the form of field_name=>[label=>input label, type=>input_type] Retrurn null if Eladmin edit profile dialog should be disabled.

actionAuthorizedDelete()

No description

final static
array
actions()

Return array of all defined actions.

from Module
final static
bool
hasAction(string $action)

Check if actions is defined.

from Module
final static
bool
isAction(string $action)

Check if actions is executed.

from Module
final static
string
parseAction(string $action)

We want action keys to be case insensitive. This converts action to lowercase.

from Module
final static
void
renderText(string|null $str = null)

Convinient method for plain text output. Sets HTTP header text/plain and echo $str.

from Module
final static
void
renderHtml(string|null $str = null)

Convinient method for html output. Sets HTTP header text/html and echo $str.

from Module
final static
void
renderJson(array|null $json = null)

Convinient method for json output. Sets HTTP header application/json and echo serialized $json.

from Module

Protected Methods

array
views()

Extends views directory.

from Crud
Blade
blade()

Return Blade instance

from Module
void
create(array $row)

IMPLEMENT. Create item.

from Crud
void
update(array $row, $id)

IMPLEMENT. Update item.

from Crud
array
default()

Read default row Returns row as an associative array ['columnName' => 'value']

from Crud
array
get($id)

IMPLEMENT. Read one row.

from Crud
void
delete($id)

IMPLEMENT. Hard delete row.

from Crud
void
softDelete($id)

IMPLEMENT. Soft delete row.

from Crud
void
restore($id)

IMPLEMENT. Restore soft deleted row.

from Crud
array
read(array $request, $totalResults)

IMPLEMENT. Fetch an array of rows.

from Crud
crudColumns()

IMPLEMENT. Default columns chainset. Override to configure columns.

crudActions()

Default actions chainset. Override to configure actions.

crudFilters()

Default filters chainset. Override to configure filters.

from Crud
id($throwIfNull = false)

Return ID of the row which should be affected by the action.

from Crud
model()

Return model instance for action.

from Crud
array
tableColumns()

Get an array of table columns.

from Crud

Private Methods

Details

in Module at line 96
__construct($core, $elakey)

Each module has to be initialized with eladmin instance and its own elakey.

Parameters

$core
$elakey

in Module at line 104
final Core core()

Return core instance

Return Value

Core

in Module at line 111
final string elakey()

Each module has its elakey - index in modules array - used to address requests.

Return Value

string

in Module at line 118
final bool auth(string|null $action = null)

Check if user is authorized to do action, or athorized to access module at all.

Parameters

string|null $action

Return Value

bool

at line 19
string title()

Get name of the module.

Return Value

string

in Module at line 140
string icon()

Get icon of the module.

Return Value

string

in Module at line 147
final string requestUrl(string|null $action = null, array $args = [])

Return url for this module.

Parameters

string|null $action
array $args

Return Value

string

in Module at line 160
final string assetUrl(string $path, string|null $version = null)

Create asset url, file path relative to /assets directory. Default $version = time()

Parameters

string $path
string|null $version

Return Value

string

in Crud at line 88
void prepare()

Runs before any action is executed.

Return Value

void

in Module at line 174
final array|null roles(string|null $action = null)

Get roles authorized to work with the module, or specific action. Empty array means any role is authorized.

Parameters

string|null $action

Return Value

array|null

in Module at line 195
private void setRoles(array|null $roles, string|null $action = null)

Set roles authorized to work with the module, or specific action. Empty array means any role is authorized.

Parameters

array|null $roles
string|null $action

Return Value

void

in Crud at line 294
protected array views()

Extends views directory.

Return Value

array

in Module at line 228
protected Blade blade()

Return Blade instance

Return Value

Blade

in Module at line 235
final string render(string $template, array $args = [])

Return rendered view.

Parameters

string $template
array $args

Return Value

string

in Module at line 243
void renderAsset(string $path)

Determinate asset content-type and render it.

Parameters

string $path

Return Value

void

in Module at line 250
final static array actions()

Return array of all defined actions.

Return Value

array

in Module at line 267
final static bool hasAction(string $action)

Check if actions is defined.

Parameters

string $action

Return Value

bool

in Module at line 274
final static bool isAction(string $action)

Check if actions is executed.

Parameters

string $action

Return Value

bool

in Module at line 281
final static string parseAction(string $action)

We want action keys to be case insensitive. This converts action to lowercase.

Parameters

string $action

Return Value

string

in Module at line 288
final static void renderText(string|null $str = null)

Convinient method for plain text output. Sets HTTP header text/plain and echo $str.

Parameters

string|null $str

Return Value

void

in Module at line 297
final static void renderHtml(string|null $str = null)

Convinient method for html output. Sets HTTP header text/html and echo $str.

Parameters

string|null $str

Return Value

void

in Module at line 306
final static void renderJson(array|null $json = null)

Convinient method for json output. Sets HTTP header application/json and echo serialized $json.

Parameters

array|null $json

Return Value

void

in Crud at line 24
bool implementsSoftDeletes()

IMPLEMENT. Does CRUD use soft deletes?

Return Value

bool

in Crud at line 36
bool implementsSearch()

IMPLEMENT. Does CRUD support searching?

Return Value

bool

in Crud at line 32
bool implementsPaging()

IMPLEMENT. Does CRUD support paging?

Return Value

bool

in Crud at line 28
bool implementsSorting()

IMPLEMENT. Does CRUD support sorting?

Return Value

bool

in Crud at line 40
bool implementsFilters()

IMPLEMENT. Does CRUD support filtering?

Return Value

bool

in Crud at line 65
string primary()

IMPLEMENT. Name of primary key column. Default is 'id'.

Return Value

string

in Crud at line 101
protected void create(array $row)

IMPLEMENT. Create item.

Parameters

array $row

Return Value

void

in Crud at line 106
protected void update(array $row, $id)

IMPLEMENT. Update item.

Parameters

array $row
$id id of item to be updated

Return Value

void

in Crud at line 182
protected array default()

Read default row Returns row as an associative array ['columnName' => 'value']

Return Value

array

in Crud at line 113
protected array get($id)

IMPLEMENT. Read one row.

Returns row as an associative array ['columnName' => 'value']

Parameters

$id

Return Value

array

in Crud at line 120
protected void delete($id)

IMPLEMENT. Hard delete row.

Parameters

$id

Return Value

void

in Crud at line 176
protected void softDelete($id)

IMPLEMENT. Soft delete row.

Parameters

$id

Return Value

void

in Crud at line 186
protected void restore($id)

IMPLEMENT. Restore soft deleted row.

Parameters

$id

Return Value

void

in Crud at line 135
protected array read(array $request, $totalResults)

IMPLEMENT. Fetch an array of rows.

Row is an associative array ['columnName' => 'value'] $totalResults needs to be set to number of results without paging applied

Parameters

array $request
$totalResults

Return Value

array

at line 111
protected crudColumns()

IMPLEMENT. Default columns chainset. Override to configure columns.

at line 98
protected crudActions()

Default actions chainset. Override to configure actions.

in Crud at line 258
protected crudFilters()

Default filters chainset. Override to configure filters.

in Crud at line 267
final Columns getCrudColumns()

Get columns chainset.

Return Value

Columns

in Crud at line 276
final Actions getCrudActions()

Get actions chainset.

Return Value

Actions

in Crud at line 285
final Filters getCrudFilters()

Get filters chainset.

Return Value

Filters

in Crud at line 302
protected id($throwIfNull = false)

Return ID of the row which should be affected by the action.

Parameters

$throwIfNull

in Crud at line 311
private rowValuesArray($row)

generate array of values for one row

Parameters

$row

in Crud at line 325
private rowActionsArray($row)

generate array of actions for one item

Parameters

$row

in Crud at line 346
private void unset(array $row)

unset columns which we shouldn't recieve before update

Parameters

array $row

Return Value

void

in Crud at line 358
private void defaults(array $row)

set defaults

Parameters

array $row

Return Value

void

in Crud at line 370
private void validate(array $row)

validate columns before update

Parameters

array $row

Return Value

void

in Crud at line 382
private void modify(array $row)

modify values before update

Parameters

array $row

Return Value

void

in Crud at line 407
actionCreateForm()

ACTION. Show form - create entry.

in Crud at line 416
actionUpdateForm()

ACTION. Show form - edit entry.

in Crud at line 425
actionRead()

ACTION. List database entries.

in Crud at line 484
actionUpdate()

ACTION. Edit database entry.

in Crud at line 495
actionCreate()

ACTION. Create database entry.

at line 167
actionDelete()

ACTION. Hard delete.

in Crud at line 515
actionSoftDelete()

ACTION. Soft delete.

in Crud at line 523
actionRestore()

ACTION. Restore.

in Crud at line 47
protected model()

Return model instance for action.

in Crud at line 72
private void updateOrCreate($entry, $row)

Update or create entry.

Parameters

$entry
$row

Return Value

void

in Crud at line 198
protected array tableColumns()

Get an array of table columns.

Return Value

array

at line 23
array|null loginFields()

Return an array of login fields in the form of field_name=>[label=>input label, type=>input_type] Retrurn null if Eladmin login dialog should be disabled (and you want to do authentication on your own)

Return Value

array|null

at line 30
void unauthorized()

This method is called when user is not autorized and loginFileds returns null.

You can redirect to your own login page. Or leave it empty to show HTTP 401.

Return Value

void

at line 34
user()

at line 39
void login(array $fields)

Eladmin calls this method during authentication.

Parameters

array $fields

Return Value

void

at line 51
void logout()

Logout.

Return Value

void

at line 55
bool authorize(array $authorizedRoles = self::ANYONE)

Check if user is logged in. Also check if user has one of the $authorizedRoles (if specified).

Parameters

array $authorizedRoles

Return Value

bool

at line 68
void accountUpdate($fields)

Eladmin calls this method during profile update.

Parameters

$fields

Return Value

void

at line 86
string userName()

Get user's name to show it in admin.

Return Value

string

at line 90
array|null accountFields()

Return an array of profile fields in the form of field_name=>[label=>input label, type=>input_type] Retrurn null if Eladmin edit profile dialog should be disabled.

Return Value

array|null

at line 161
actionAuthorizedDelete()