Building a site
Your own screens and models
Admin screens, models published like pages, and menu panels for what the website adds.
A website often has more than pages: events, products, a team. Its own models and Filament screens join Aurora's admin from a service provider, through Aurora\Support\AdminPanel.
Admin screens
use Aurora\Support\AdminPanel;
// Every resource and page in a folder and its subfolders…
AdminPanel::discover(app_path('Filament/Resources'), 'App\Filament\Resources', perSite: true);
// …or name them.
AdminPanel::resources([EventResource::class], perSite: true);
AdminPanel::pages([Reports::class]);
// A sidebar group of their own: after Content, or after: 'AI', or after one of yours.
AdminPanel::navigationGroup('Events', fn (): string => __('Events'));
- Groups: a resource joins a group by its
$navigationGroupname ('Events'above). Groups after the same one keep the order they're registered in. - Each site's own records: the admin is per site (
/admin/{site}/…). A website's resources show every site's records, unless they're registered withperSite: true, for a model with asiterelation. - Labels: name screens and fields with
__(). A line in the app'slang/{locale}.jsonis the label straight away, and beats Aurora's own; only what's edited under Translations beats the app's file.
Published like a page
A model that is drafted, scheduled and published like a page uses Aurora\Models\Concerns\HasPublishing, with its columns in the migration:
use Aurora\Models\Concerns\HasPublishing;
class Event extends Model
{
use HasPublishing;
}
// In its migration: status, published_at and unpublish_at.
Schema::create('events', function (Blueprint $table) {
$table->uuid('id')->primary();
$table->string('title');
Event::publishingColumns($table);
$table->timestamps();
});
// What visitors may see.
Event::query()->live()->get();
$event->isLive();
$event->isScheduled();
$event->hasEnded();
Its resource gets the page form's publishing fields, the status column and the status filter from Aurora\Filament\Publishing:
use Aurora\Filament\Publishing;
public static function form(Schema $schema): Schema
{
return $schema->components([
TextInput::make('title')->label(__('Title')),
Publishing::section(),
]);
}
public static function table(Table $table): Table
{
return $table
->columns([TextColumn::make('title'), Publishing::column()])
->filters([Publishing::filter()]);
}
Menu panels
The menu editor offers pages and custom links. Add panels for the website's own addresses with Menus::panels(): a StaticMenuPanel of fixed links, or a ModelMenuPanel for a model that implements MenuPanelable.
use Aurora\Support\Menus;
use Datlechin\FilamentMenuBuilder\MenuPanel\StaticMenuPanel;
Menus::panels([
StaticMenuPanel::make(__('Website'))->add(__('Events'), '/events'),
]);
// /events is in every language, under its prefix: in Norwegian the link goes to /no/events.
Menus::localized(['/events']);