Copy config/eropadevcom/admin/example/entity.php to entities/products.php:
<?php
return [
'label' => 'admin::entities.products.label',
'model' => App\Models\Product::class,
'roles' => ['admin'],
'with' => ['category'],
'order' => ['id' => 'desc'],
'crud' => ['create' => true, 'edit' => true, 'delete' => true],
'api' => ['enabled' => true],
'fields' => [
['name' => 'name', 'type' => 'text', 'rules' => ['required', 'string', 'max:255']],
['name' => 'price', 'type' => 'number', 'rules' => ['required', 'numeric', 'min:0']],
['name' => 'is_active', 'type' => 'checkbox', 'rules' => ['nullable', 'boolean']],
['name' => 'cover', 'type' => 'image', 'rules' => ['nullable', 'image', 'max:5120']],
[
'name' => 'gallery',
'type' => 'media',
'multiple' => true,
'kinds' => ['image', 'video'],
'rules' => ['nullable', 'array'],
'rules.*' => ['file', 'max:51200'],
],
],
'relations' => [
'tags' => [
'type' => 'belongsToMany',
'input' => 'tag_ids',
'display' => 'name',
'model' => App\Models\Tag::class,
],
],
'columns' => [
['key' => 'id', 'label' => 'ID'],
['key' => 'name', 'label' => 'Name'],
['key' => 'price', 'label' => 'Price'],
['key' => 'is_active', 'label' => 'Active', 'type' => 'boolean'],
],
];
Add to menu:
['entity' => 'products'],
You immediately get:
- UI:
/admin/entities/products - API:
/admin/api/entities/products
No custom controller. Validation rules stay next to the field definition.