Generics Overview ​
Generics are cross-cutting utilities and patterns that any module can use. Unlike Module Features (which follow the Entity + Repository + Hydrate triple pattern), generics are lightweight traits and conventions applied wherever they're useful — controllers, arrays, route configs, models.
At a Glance ​
| Generic | Layer | Solves | Entry point |
|---|---|---|---|
| Allowable | Controller trait | Role-based filtering of arrays / collections (menus, actions, widgets) | use Allowable + allowedRoles key |
| Responsive Visibility | Controller trait | Show/hide array items per Vuetify breakpoint | use ResponsiveVisibility + responsive key |
| File Storage with Filepond | Model trait + input | One-to-many polymorphic file uploads via FilePond | use HasFileponds + type: filepond |
| Relationships | CLI + runtime | Eloquent relationship generation and conventions | --relationships on make:model / make:route |
Decision Guide ​
Need to filter a list by user role? → Allowable
Need to hide menu items on mobile? → Responsive Visibility
Need users to upload files (avatar, attachments)? → File Storage with Filepond
Defining a new module and its relations? → Relationships
Need the full feature triple (Entity + Repository + Hydrate)? → Check Module Features instead.
Quick Examples ​
Allowable — Filter by Role ​
use Unusualify\Modularous\Traits\Allowable;
class NavigationController extends Controller
{
use Allowable;
public function items()
{
return $this->getAllowableItems([
['title' => 'Home', 'route' => 'home'],
['title' => 'Admin', 'route' => 'admin', 'allowedRoles' => ['admin']],
]);
}
}Items without allowedRoles are public. See Allowable for closures, guards, and custom search keys.
Responsive Visibility — Breakpoint Control ​
use Unusualify\Modularous\Traits\ResponsiveVisibility;
class MenuController extends Controller
{
use ResponsiveVisibility;
public function items()
{
return $this->getResponsiveItems([
['title' => 'Desktop Search', 'responsive' => ['hideBelow' => 'md']],
['title' => 'Mobile Menu', 'responsive' => ['hideAbove' => 'md']],
]);
}
}Applies Vuetify d-{breakpoint}-* classes. See Responsive Visibility for all modifiers (hideOn, showOn, hideBelow, hideAbove, breakpoints).
Filepond — Upload in Three Lines ​
Model:
use Unusualify\Modularous\Entities\Traits\HasFileponds;
class Ticket extends Model
{
use HasFileponds;
}Route config:
'inputs' => [
['type' => 'filepond', 'name' => 'attachments', 'max' => 5],
]Repository:
use Unusualify\Modularous\Repositories\Traits\FilepondsTrait;
class TicketRepository extends Repository
{
use FilepondsTrait;
}See File Storage with Filepond for storage mechanics and Files and Media for the full triple pattern.
Relationships — Define at Generation Time ​
# Model-level (adds method to parent model)
php artisan modularous:make:model Package Billing \
--relationships="belongsToMany:Feature"
# Route-level (creates pivot + migration + reverse relation)
php artisan modularous:make:route Billing packages \
--relationships="Feature:belongsToMany,position:integer:unsigned:index"See Relationships for full grammar, field types, and modifiers.
Composing Generics ​
Generics are independent, so you can stack them. The most common combo is Allowable + ResponsiveVisibility on the same menu:
use Unusualify\Modularous\Traits\{Allowable, ResponsiveVisibility};
class MenuController extends Controller
{
use Allowable, ResponsiveVisibility;
public function items()
{
$items = [
[
'title' => 'Admin Panel',
'allowedRoles' => ['admin'],
'responsive' => ['hideBelow' => 'md'],
],
];
// Order matters: filter by role first, then apply CSS classes
return $this->getResponsiveItems(
$this->getAllowableItems($items)
);
}
}Where Generics Live ​
| Generic | FQCN |
|---|---|
| Allowable | Unusualify\Modularous\Traits\Allowable |
| ResponsiveVisibility | Unusualify\Modularous\Traits\ResponsiveVisibility |
| HasFileponds | Unusualify\Modularous\Entities\Traits\HasFileponds |
| FilepondsTrait | Unusualify\Modularous\Repositories\Traits\FilepondsTrait |
Related ​
- Module Features — full feature patterns (Entity + Repository + Hydrate)
- Files and Media — Files / Images / Filepond side-by-side
- Hydrates — how form schema is generated