Enhance Group and Document resources; add leader and helper teacher relationships, update navigation icons, and adjust navigation sorting.
This commit is contained in:
@@ -11,20 +11,23 @@ use App\Models\Document;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
|
||||
class DocumentResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Document::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedRectangleStack;
|
||||
|
||||
protected static ?string $navigationLabel = 'Resminamalar';
|
||||
|
||||
protected static ?string $pluralLabel = 'Resminamalar';
|
||||
|
||||
protected static ?int $navigationSort = 3;
|
||||
protected static ?int $navigationSort = 4;
|
||||
|
||||
public static function getNavigationIcon(): string | BackedEnum | Htmlable | null
|
||||
{
|
||||
return 'heroicon-o-document-text';
|
||||
}
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
|
||||
@@ -12,7 +12,6 @@ use App\Models\Group;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
|
||||
@@ -20,8 +19,6 @@ class GroupResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Group::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedRectangleStack;
|
||||
|
||||
protected static ?string $navigationLabel = 'Toparlar';
|
||||
|
||||
protected static ?string $pluralLabel = 'Toparlar';
|
||||
@@ -32,7 +29,7 @@ class GroupResource extends Resource
|
||||
|
||||
public static function getNavigationIcon(): string | BackedEnum | Htmlable | null
|
||||
{
|
||||
return 'heroicon-o-user-group';
|
||||
return 'icon-flight-takeoff';
|
||||
}
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
|
||||
namespace App\Filament\Resources\Groups\Schemas;
|
||||
|
||||
use App\Models\Teacher;
|
||||
use Carbon\Carbon;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Schemas\Components\Utilities\Set;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
@@ -22,6 +24,19 @@ class GroupForm
|
||||
DatePicker::make('end_date')
|
||||
->label('Gutarýan senesi')
|
||||
->required(),
|
||||
|
||||
Select::make('leader_teacher_id')
|
||||
->label('Topar başy')
|
||||
->options(Teacher::query()->pluck('name', 'id'))
|
||||
->searchable()
|
||||
->required(),
|
||||
|
||||
Select::make('helperTeachers')
|
||||
->label('Topar kömekçileri')
|
||||
->relationship('helperTeachers', 'name')
|
||||
->multiple()
|
||||
->searchable()
|
||||
->preload(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,11 @@ class GroupsTable
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('leaderTeacher.name')
|
||||
->label('Topar başy')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
|
||||
TextColumn::make('start_date')
|
||||
->label('Başlanýan senesi')
|
||||
->date()
|
||||
|
||||
11
app/Filament/Resources/Teachers/Pages/CreateTeacher.php
Normal file
11
app/Filament/Resources/Teachers/Pages/CreateTeacher.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Teachers\Pages;
|
||||
|
||||
use App\Filament\Resources\Teachers\TeacherResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateTeacher extends CreateRecord
|
||||
{
|
||||
protected static string $resource = TeacherResource::class;
|
||||
}
|
||||
19
app/Filament/Resources/Teachers/Pages/EditTeacher.php
Normal file
19
app/Filament/Resources/Teachers/Pages/EditTeacher.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Teachers\Pages;
|
||||
|
||||
use App\Filament\Resources\Teachers\TeacherResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditTeacher extends EditRecord
|
||||
{
|
||||
protected static string $resource = TeacherResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
19
app/Filament/Resources/Teachers/Pages/ListTeachers.php
Normal file
19
app/Filament/Resources/Teachers/Pages/ListTeachers.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Teachers\Pages;
|
||||
|
||||
use App\Filament\Resources\Teachers\TeacherResource;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListTeachers extends ListRecords
|
||||
{
|
||||
protected static string $resource = TeacherResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
16
app/Filament/Resources/Teachers/Schemas/TeacherForm.php
Normal file
16
app/Filament/Resources/Teachers/Schemas/TeacherForm.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Teachers\Schemas;
|
||||
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class TeacherForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
//
|
||||
]);
|
||||
}
|
||||
}
|
||||
30
app/Filament/Resources/Teachers/Tables/TeachersTable.php
Normal file
30
app/Filament/Resources/Teachers/Tables/TeachersTable.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Teachers\Tables;
|
||||
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class TeachersTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
//
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
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