Enhance Group and Document resources; add leader and helper teacher relationships, update navigation icons, and adjust navigation sorting.
This commit is contained in:
101
app/Filament/Resources/Teachers/TeacherResource.php
Normal file
101
app/Filament/Resources/Teachers/TeacherResource.php
Normal file
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Teachers;
|
||||
|
||||
use App\Filament\Resources\Teachers\Pages\CreateTeacher;
|
||||
use App\Filament\Resources\Teachers\Pages\EditTeacher;
|
||||
use App\Filament\Resources\Teachers\Pages\ListTeachers;
|
||||
use App\Models\Teacher;
|
||||
use BackedEnum;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction as ActionsEditAction;
|
||||
use Filament\Forms;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
|
||||
class TeacherResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Teacher::class;
|
||||
|
||||
protected static ?string $navigationLabel = 'Mugallymlar';
|
||||
|
||||
protected static ?string $pluralLabel = 'Mugallymlar';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
protected static ?int $navigationSort = 3;
|
||||
|
||||
public static function getNavigationIcon(): string | BackedEnum | Htmlable | null
|
||||
{
|
||||
return 'heroicon-o-user-group';
|
||||
}
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('name')
|
||||
->required()
|
||||
->maxLength(255),
|
||||
Forms\Components\FileUpload::make('photo')
|
||||
->image(),
|
||||
Forms\Components\Textarea::make('bio')
|
||||
->columnSpanFull(),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\ImageColumn::make('photo')
|
||||
->label('Surat')
|
||||
->circular(),
|
||||
|
||||
Tables\Columns\TextColumn::make('name')
|
||||
->label('Ady')
|
||||
->searchable(),
|
||||
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->recordActions([
|
||||
ActionsEditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListTeachers::route('/'),
|
||||
'create' => CreateTeacher::route('/create'),
|
||||
'edit' => EditTeacher::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user