//crear resource Personcomposer require doctrine/dbal
php artisan make:filament-resource Person --generate
<?php
namespace App\Filament\Resources;
use App\Filament\Resources\PersonResource\Pages;
use App\Filament\Resources\PersonResource\RelationManagers;
use App\Models\Person;
use Filament\Forms;
use Filament\Resources\Form;
use Filament\Resources\Resource;
use Filament\Resources\Table;
use Filament\Tables;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Forms\Components\FileUpload;
use Filament\Tables\Columns\ImageColumn;
use Filament\Forms\Components\Select;
class PersonResource extends Resource
{
protected static ?string $model = Person::class;
protected static ?string $navigationIcon = 'heroicon-o-collection';
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\TextInput::make('nom')
->required()
->maxLength(255),
Forms\Components\FileUpload::make('img'),
Forms\Components\Select::make('categoria')
->options([
'photographers' => 'photographers',
'painters' => 'painters',
'influencers' => 'influencers',
'music' => 'music',
'models' => 'models',
'esports' => 'espòrts',
]),
Forms\Components\Select::make('vestit')
->options([
'vestit' => 'vestit',
'nu' => 'nu',
'linguerie' => 'linguerie',
]),
Forms\Components\Select::make('cabell')
->options([
'rossa' => 'rossa',
'morena' => 'morena',
'pelroja' => 'pelroja',
]),
Forms\Components\Select::make('origen')
->options([
'caucasica' => 'caucasica',
'negra' => 'negra',
'asiatica' => 'asiatica',
'catalan' => 'catalan',
'spanish' => 'spanish',
'asia' => 'asia',
'africa' => 'africa',
'north_america' => 'north_america',
'south_america' => 'south_america',
'antarctica' => 'antarctica',
'europe' => 'europe',
'australia' => 'australia',
]),
Forms\Components\TextInput::make('folder')
->maxLength(255),
Forms\Components\TextInput::make('ins')
->maxLength(255),
Forms\Components\TextInput::make('face')
->maxLength(255),
Forms\Components\TextInput::make('mp3')
->maxLength(255),
Forms\Components\TextInput::make('web')
->maxLength(255),
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('nom')->limit(10),
Tables\Columns\ImageColumn::make('img')->width(35),
Tables\Columns\TextColumn::make('categoria')->limit(10),
Tables\Columns\TextColumn::make('vestit')->limit(10),
Tables\Columns\TextColumn::make('cabell')->limit(10),
Tables\Columns\TextColumn::make('origen')->limit(10),
Tables\Columns\TextColumn::make('folder')->limit(10),
Tables\Columns\TextColumn::make('ins')->limit(10),
Tables\Columns\TextColumn::make('face')->limit(10),
Tables\Columns\TextColumn::make('mp3')->limit(10),
Tables\Columns\TextColumn::make('updated_at')
->dateTime(),
Tables\Columns\TextColumn::make('web'),
])
->filters([
//
])
->actions([
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\DeleteBulkAction::make(),
]);
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListPeople::route('/'),
'create' => Pages\CreatePerson::route('/create'),
'edit' => Pages\EditPerson::route('/{record}/edit'),
];
}
}