1. Fields
The$fields parameter defines every database column, every form input, the validation rules and the data shown in the record listing.
Static fields
Dynamically generated fields
When fields are generated dynamically, you can change the rules for saving a record — the currently edited record is passed to the method.2. Basic parameters
Creation date
$migration_date holds the date and time the model was created. The administration uses it to order the modules and build the structure in the right sequence.
Required parameter, generated automatically. One date can belong to at most one admin model.
Module name
The name of the section in the administration.
Required parameter, generated automatically.
Module description
The optional description of the section in the administration.
Module group
An admin model can be assigned to a subgroup defined in the system configuration.
Localization
Allows a unique translation of the content for every language version of the site.Each module gets unique records per language version, and a foreign key to the
languages table is created automatically.Relations between models
$belongsToModel defines the relationship between two or more admin models.
Foreign keys between the tables are created automatically.
Automatic URL generation
$sluggable generates URL addresses from the value of a column. Useful for content whose URL carries a formatted value that is then used to look the record up.
A
slug column is created in the table, holding the value of the chosen column without diacritics and in nice URL form.Change history
Enables the history of changes made to records.
Change history also has to be enabled in the administration configuration.
Disabling the module
When you need the database table without generating an administration interface, or you simply want to hide the module, set the value tofalse.
Skipping column removal during migrations
If your admin model is attached to an existing table shared with another project, which contains columns the admin model does not define, list those columns so they are ignored.3. Content restrictions
Each module needs its own content rules — the maximum or minimum number of records, whether records can be reordered by drag and drop, whether they can be published or deleted.Creating records
Set tofalse to forbid creating new records in the section.
Editing records
Set tofalse to forbid editing existing records in the section.
Deleting records
Set tofalse to forbid deleting existing records in the section.
Publishing records
Set totrue to allow publishing and hiding records in the section.
A
published_at column is created in the table, holding the publication state of the record.Reordering records
Set tofalse to forbid moving records by drag and drop. Reordering is enabled on every admin model by default.
An
_order column is created in the table, holding the position of the record. Records selected through the Eloquent model are ordered by it automatically.Minimum number of records
Once the minimum number of records is reached, the administration hides the option to delete records.The value
0 means no limit.Maximum number of records
Once the maximum number of records is reached, the administration hides the option to add new records.The value
0 means no limit.Single record mode
$single switches the interface into single-record mode by setting $minimum and $maximum to 1. The record listing is hidden and the page contains only the form for editing one record.
In this mode
$sortable and $publishable are set to false, which affects the database migration.4. Additional settings
Additional settings target specific behaviours of the admin model — form texts, table rules and similar options. They are defined in the$settings property or the settings() method.
Form texts
Column names and order
Use these parameters to hide a column, limit its text length or change its default name.Adding new columns
You can add columns that carry no value from an existing database column and assign them any value, including HTML that will be rendered.Columns loaded by the query
setAdminAttributes runs for every row. When a column needs data from another table, a query inside it runs once per row. Load the value in the query of the table instead, with the scopeAdminRows scope.
app/Models/Package/Package.php
makeVisible in setAdminRowsResponse.
Visibility can be changed in three methods, which run before the attributes are rendered:
Custom buttons in the side panel
The side panel of a record, which holds the delete and publish buttons, can be extended through$buttons.