56 lines
2.2 KiB
PHP
56 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\Projects;
|
|
|
|
use App\Filament\Resources\Projects\Pages;
|
|
use App\Models\Project;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Forms\Components\Select;
|
|
use Filament\Schemas\Components\Section;
|
|
use Filament\Schemas\Schema;
|
|
use Filament\Resources\Resource;
|
|
use Filament\Tables;
|
|
use Filament\Tables\Table;
|
|
|
|
class ProjectResource extends Resource
|
|
{
|
|
protected static ?string $model = Project::class;
|
|
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-building-office-2';
|
|
protected static string | \UnitEnum | null $navigationGroup = 'Quản lý Dự án';
|
|
|
|
public static function form(Schema $schema): Schema
|
|
{
|
|
return $schema
|
|
->components([
|
|
Section::make('Thông tin Dự án')
|
|
->columns(2)
|
|
->schema([
|
|
TextInput::make('name')->label('Tên Dự án')->required()->maxLength(255),
|
|
Select::make('type')->label('Loại hình')->options(['Khu đô thị' => 'Khu đô thị', 'Chung cư' => 'Chung cư', 'Đất nền phân lô' => 'Đất nền phân lô', 'Khu nghỉ dưỡng' => 'Khu nghỉ dưỡng'])->required(),
|
|
TextInput::make('address')->label('Địa chỉ chi tiết')->columnSpanFull(),
|
|
])
|
|
]);
|
|
}
|
|
|
|
public static function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
Tables\Columns\TextColumn::make('name')->label('Tên Dự án')->searchable()->sortable(),
|
|
Tables\Columns\TextColumn::make('type')->label('Loại hình')->badge()->sortable(),
|
|
Tables\Columns\TextColumn::make('address')->label('Địa chỉ')->limit(50),
|
|
Tables\Columns\TextColumn::make('created_at')->label('Ngày tạo')->dateTime('d/m/Y')->sortable()->toggleable(isToggledHiddenByDefault: true),
|
|
])
|
|
->defaultSort('created_at', 'desc');
|
|
}
|
|
|
|
public static function getPages(): array
|
|
{
|
|
return [
|
|
'index' => Pages\ListProjects::route('/'),
|
|
'create' => Pages\CreateProject::route('/create'),
|
|
'edit' => Pages\EditProject::route('/{record}/edit'),
|
|
];
|
|
}
|
|
}
|