Adds a Filament admin (Profile settings page plus CRUD resources for Education, Experience, Projects, and Posts) backing a public-facing personal site: hero/about/timeline home page, project showcase, and blog, styled with a dark editorial theme (Fraunces + Instrument Sans). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
81 lines
2.3 KiB
PHP
81 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Pages;
|
|
|
|
use App\Models\Profile;
|
|
use BackedEnum;
|
|
use Filament\Forms\Components\FileUpload;
|
|
use Filament\Forms\Components\KeyValue;
|
|
use Filament\Forms\Components\RichEditor;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Notifications\Notification;
|
|
use Filament\Pages\Page;
|
|
use Filament\Schemas\Schema;
|
|
use Filament\Support\Icons\Heroicon;
|
|
|
|
class ManageProfile extends Page
|
|
{
|
|
protected string $view = 'filament.pages.manage-profile';
|
|
|
|
protected static ?string $navigationLabel = 'Profile';
|
|
|
|
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedUser;
|
|
|
|
protected static ?int $navigationSort = -1;
|
|
|
|
/**
|
|
* @var array<string, mixed>|null
|
|
*/
|
|
public ?array $data = [];
|
|
|
|
public function mount(): void
|
|
{
|
|
$this->form->fill(Profile::query()->first()?->toArray() ?? []);
|
|
}
|
|
|
|
public function defaultForm(Schema $schema): Schema
|
|
{
|
|
return $schema->statePath('data');
|
|
}
|
|
|
|
public function form(Schema $schema): Schema
|
|
{
|
|
return $schema
|
|
->components([
|
|
TextInput::make('name')
|
|
->required(),
|
|
TextInput::make('headline')
|
|
->helperText('A short tagline shown under your name, e.g. "Backend developer & tinkerer".'),
|
|
RichEditor::make('bio')
|
|
->columnSpanFull(),
|
|
TextInput::make('location'),
|
|
TextInput::make('email')
|
|
->email(),
|
|
FileUpload::make('avatar')
|
|
->image()
|
|
->disk('public')
|
|
->directory('profile'),
|
|
FileUpload::make('resume_path')
|
|
->label('Resume / CV')
|
|
->disk('public')
|
|
->directory('profile'),
|
|
KeyValue::make('social_links')
|
|
->keyLabel('Platform')
|
|
->valueLabel('URL')
|
|
->columnSpanFull(),
|
|
]);
|
|
}
|
|
|
|
public function save(): void
|
|
{
|
|
$data = $this->form->getState();
|
|
|
|
Profile::query()->first()?->update($data) ?? Profile::create($data);
|
|
|
|
Notification::make()
|
|
->title('Profile saved')
|
|
->success()
|
|
->send();
|
|
}
|
|
}
|