php artisan make:filament-resource Tool
<?php
namespace App\Filament\Resources;
use App\Filament\Resources\ToolResource\Pages;
use App\Filament\Resources\ToolResource\RelationManagers;
use App\Models\Tool;
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;
class ToolResource extends Resource
{
protected static ?string $model = Tool::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\MarkdownEditor::make('descripcio')
->columnSpan('full'),
Forms\Components\MarkdownEditor::make('body')
->columnSpan('full'),
Forms\Components\Select::make('categoria')
->options([
'requisits' => 'requisits',
'formacio' => 'formacio',
'framework' => 'framework',
'css' => 'css',
'themes' => 'themes',
'llibreries' => 'llibreries',
'icons' => 'icons',
]),
Forms\Components\TextInput::make('youtube')
->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)
->searchable()
->sortable(),
Tables\Columns\ImageColumn::make('img')->width(35),
Tables\Columns\TextColumn::make('descripcio')->limit(15)
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('categoria')->limit(10)
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('youtube')->limit(5),
Tables\Columns\TextColumn::make('web')->limit(5)
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('updated_at')
->dateTime(),
])
->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\ListTools::route('/'),
'create' => Pages\CreateTool::route('/create'),
'edit' => Pages\EditTool::route('/{record}/edit'),
];
}
}