Files
gujurly.com/app/Filament/Resources/AuthorResource.php

99 lines
3.0 KiB
PHP

<?php
namespace App\Filament\Resources;
use App\Filament\Resources\AuthorResource\Pages;
use App\Filament\Resources\AuthorResource\RelationManagers;
use App\Models\Author;
use Filament\Forms;
use Filament\Forms\Components\FileUpload;
use Filament\Forms\Components\RichEditor;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Columns\ImageColumn;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
class AuthorResource extends Resource
{
protected static ?string $model = Author::class;
protected static ?string $navigationIcon = 'heroicon-o-users';
protected static ?string $navigationGroup = 'News';
public static function form(Form $form):
Form
{
return $form
->schema([
Forms\Components\Card::make()
->schema([
TextInput::make('name')
->required()
->maxLength(255),
FileUpload::make('profile_image')
->label('Profile Image 400x400')
->image()
->directory('authors')
->nullable(),
RichEditor::make('description')
->nullable()
->columnSpanFull(),
])->columns(1),
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
ImageColumn::make('profile_image')
->square()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('name')
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('created_at')
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('updated_at')
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
])
->filters([
//
])
->actions([
Tables\Actions\EditAction::make(),
Tables\Actions\DeleteAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
]);
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListAuthors::route('/'),
'create' => Pages\CreateAuthor::route('/create'),
'edit' => Pages\EditAuthor::route('/{record}/edit'),
];
}
}