This package contains various Eloquent models for managing CMS functionality.
The MantaRoute
model manages Laravel routes in the database for route-based navigation and permissions.
Table: manta_routes
Field | Type | Description |
---|---|---|
id |
bigint | Primary key |
uri |
string | Route URI (e.g. ‘cms/dashboard’) |
name |
string | Route name (e.g. ‘cms.dashboard’) |
prefix |
string | Route prefix (e.g. ‘cms’) |
active |
boolean | Whether the route is active (default: 1) |
created_by |
bigint | ID of user who created the record |
updated_by |
bigint | ID of user who updated the record |
created_at |
timestamp | Creation timestamp |
updated_at |
timestamp | Update timestamp |
use Manta\FluxCMS\Models\MantaRoute;
// Retrieve all active routes
$activeRoutes = MantaRoute::active()->get();
// Filter routes by prefix
$cmsRoutes = MantaRoute::byPrefix('cms')->get();
// Specific CMS routes (shortcut)
$cmsRoutes = MantaRoute::cms()->get();
// Find route by name
$dashboardRoute = MantaRoute::where('name', 'cms.dashboard')->first();
// Create new route
$route = MantaRoute::create([
'uri' => 'cms/settings',
'name' => 'cms.settings',
'prefix' => 'cms',
'active' => true
]);
scopeActive($query)
Filters only active routes:
$activeRoutes = MantaRoute::active()->get();
scopeByPrefix($query, $prefix)
Filters routes by prefix:
$adminRoutes = MantaRoute::byPrefix('admin')->get();
scopeCms($query)
Shortcut for CMS routes (prefix = ‘cms’):
$cmsRoutes = MantaRoute::cms()->get();
protected $fillable = [
'uri',
'name',
'prefix',
'active',
'created_by',
'updated_by'
];
protected $casts = [
'active' => 'boolean'
];
The model automatically fills the created_by
and updated_by
fields with the ID of the logged-in user when creating and updating records.
Routes can be synchronized from Laravel’s route definition with the manta:sync-routes
command:
# Synchronize all routes
php artisan manta:sync-routes
# Only CMS routes
php artisan manta:sync-routes --prefix=cms
All models can be found in the src/Models
directory. They follow standard Laravel conventions and contain relationships and scopes relevant to the CMS.
The models are enhanced with type hints, query scopes, relationships and PHPDoc annotations for better IDE support and developer experience.
Example of using a model with query scopes:
// Example of using a model
use Manta\FluxCMS\Models\User;
// Get all active admin users
$admins = User::active()->admin()->get();
// Search by name or email
$searchResults = User::search('Johnson')->get();
// Filter by company
$companyUsers = User::byCompany(5)->get();
For detailed documentation of individual models, see the model files in /src/Models/
.