Creating records
Set tofalse to forbid creating new records. The add button is hidden, the server refuses the form request and the insert permission is no longer offered in user groups.
Editing records
Set tofalse to forbid editing records. The server refuses the form request. The update permission stays available in user groups.
Read-only preview
To let administrators open records of a read-only module in a disabled form, enable$displayable.
Administrators with the
read permission but without update always open records as a preview.Deleting records
Set tofalse to forbid deleting records. The delete button is not rendered and the delete permission is not offered in user groups.
canDelete(). Only true allows deleting.
Delete options
Instead oftrue, an array of options changes how records are deleted.
Checking deletion in code
canBeDeleted() combines canDelete(), the delete permission of the logged administrator, $deletable, $minimum and $reserved. Custom buttons can use the same check as the delete button.
['reserved' => false] to skip the reserved check.
Reserved records
List the ids of records which must never be deleted, for example a default language or the main administrator account. Every other record in the module can still be deleted.reserved() method instead:
setReservedProperty($ids) mutator, on the model itself or in a model module.
Reserved records only restrict deleting. They can still be edited, published or hidden.
User groups
Enable user groups withadmin_roles. A User groups module appears in the administration, where each group is granted permissions per module: read, insert, update, publishable and delete.
- Super administrators have full access.
- Other administrators get the merged permissions of all their groups.
- Without
readthe module table stays empty and records can not be opened. Withoutinsertorupdatethe form requests are refused, withoutupdaterecords can not be reordered. - Permissions follow the resolved model parameters, a module with
insertable()returningfalseoffers noinsertpermission.
Checking permissions
'*' returns false.
Custom permissions
Add your own permission keys to a module. They appear in the user group editor and can be checked withhasAccess(). defaultModelPermissions() returns the default keys of the module.
Own account only
In the administrators module, users without the View other users (view_others) permission see and edit only their own account, and the module opens as a single form. Override canViewAllRowsAccordingToLoggedUser() on the auth model to add your own rules.
Restricting records by assignment
When administrators belong to a company, branch or school, return the assignment columns fromfilterRowsByColumns() on the auth model. Every module then shows only related records.
app/Models/User.php
schoolslists only the assigned school, child models ofSchoolare filtered byschool_id.- Other modules are filtered by relation fields with the
hasAccessFilterparameter. - A
belongsToManycolumn filters by all assigned ids.
Private files
Files of a field with theprivate parameter, or of all fields when $privateUploads = true, are served in the administration only to logged administrators with the read permission of the module. See private files.