Refactor Filament resources and models; add attribute casting in Group model, update navigation icons, and remove TeacherSeeder in favor of UserTableSeeder.
This commit is contained in:
@@ -14,11 +14,6 @@ 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()
|
||||
@@ -29,6 +24,11 @@ class GroupsTable
|
||||
->date()
|
||||
->sortable(),
|
||||
|
||||
TextColumn::make('leaderTeacher.name')
|
||||
->label('Topar başy')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
|
||||
TextColumn::make('created_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
|
||||
@@ -13,20 +13,24 @@ use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Icons\Heroicon;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class PilgrimResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Pilgrim::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedRectangleStack;
|
||||
|
||||
protected static ?string $navigationLabel = 'Zyýaratçylar';
|
||||
|
||||
protected static ?string $pluralLabel = 'Zyýaratçylar';
|
||||
|
||||
protected static ?int $navigationSort = 2;
|
||||
|
||||
public static function getNavigationIcon(): string | BackedEnum | Htmlable | null
|
||||
{
|
||||
return 'icon-pilgrim-man';
|
||||
}
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return PilgrimForm::configure($schema);
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Casts\Attribute;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
@@ -19,6 +20,21 @@ class Group extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
/**
|
||||
* @var array<string, string>
|
||||
*/
|
||||
protected $casts = [
|
||||
'start_date' => 'date',
|
||||
'end_date' => 'date',
|
||||
];
|
||||
|
||||
public function name(): Attribute
|
||||
{
|
||||
return Attribute::make(
|
||||
get: fn ($value) => $this->start_date->format('d M') . ' - ' . $this->end_date->format('d M'),
|
||||
);
|
||||
}
|
||||
|
||||
public function pilgrims(): HasMany
|
||||
{
|
||||
return $this->hasMany(Pilgrim::class);
|
||||
|
||||
@@ -7,6 +7,14 @@ use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
* @property string $name
|
||||
* @property string $photo
|
||||
* @property string $bio
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
*/
|
||||
class Teacher extends Model
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\TeacherFactory> */
|
||||
|
||||
Reference in New Issue
Block a user