feat: initialize Dr-Panel project with patient file number support
This commit is contained in:
@@ -0,0 +1,165 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\LabTestResource\Pages;
|
||||
use App\Models\LabTest;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Components\Grid;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class LabTestResource extends Resource
|
||||
{
|
||||
protected static ?string $model = LabTest::class;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
public static function getNavigationIcon(): \BackedEnum|string|null
|
||||
{
|
||||
return 'heroicon-o-beaker';
|
||||
}
|
||||
|
||||
public static function getNavigationGroup(): ?string
|
||||
{
|
||||
return __('navigation.groups.diseases');
|
||||
}
|
||||
|
||||
public static function getNavigationSort(): ?int
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
return __('navigation.lab_tests.title');
|
||||
}
|
||||
|
||||
public static function getModelLabel(): string
|
||||
{
|
||||
return __('navigation.lab_tests.singular');
|
||||
}
|
||||
|
||||
public static function getPluralModelLabel(): string
|
||||
{
|
||||
return __('navigation.lab_tests.title');
|
||||
}
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Grid::make()
|
||||
->schema([
|
||||
Section::make(__('lab_tests.sections.info'))
|
||||
->schema([
|
||||
TextInput::make('name')
|
||||
->label(__('lab_tests.fields.name'))
|
||||
->required()
|
||||
->maxLength(255),
|
||||
|
||||
Textarea::make('notes')
|
||||
->label(__('lab_tests.fields.notes'))
|
||||
->rows(2)
|
||||
->columnSpanFull(),
|
||||
|
||||
Toggle::make('is_default')
|
||||
->label(__('lab_tests.fields.is_default')),
|
||||
|
||||
Toggle::make('is_active')
|
||||
->label(__('lab_tests.fields.is_active'))
|
||||
->default(true),
|
||||
])
|
||||
->columns(3)
|
||||
->columnSpanFull()
|
||||
->footerActions([
|
||||
fn (string $operation) => Action::make('create')
|
||||
->label(__('filament-panels::resources/pages/create-record.form.actions.create.label'))
|
||||
->submit('create')
|
||||
->keyBindings(['mod+s'])
|
||||
->visible($operation === 'create'),
|
||||
|
||||
fn (string $operation) => Action::make('createAnother')
|
||||
->label(__('filament-panels::resources/pages/create-record.form.actions.create_another.label'))
|
||||
->action('createAnother')
|
||||
->keyBindings(['mod+shift+s'])
|
||||
->color('gray')
|
||||
->visible($operation === 'create'),
|
||||
|
||||
fn (string $operation) => Action::make('cancelCreate')
|
||||
->label(__('filament-panels::resources/pages/create-record.form.actions.cancel.label'))
|
||||
->url(static::getUrl('index'))
|
||||
->color('gray')
|
||||
->visible($operation === 'create'),
|
||||
|
||||
fn (string $operation) => Action::make('save')
|
||||
->label(__('filament-panels::resources/pages/edit-record.form.actions.save.label'))
|
||||
->submit('save')
|
||||
->keyBindings(['mod+s'])
|
||||
->visible($operation === 'edit'),
|
||||
|
||||
fn (string $operation) => Action::make('cancelEdit')
|
||||
->label(__('filament-panels::resources/pages/edit-record.form.actions.cancel.label'))
|
||||
->url(static::getUrl('index'))
|
||||
->color('gray')
|
||||
->visible($operation === 'edit'),
|
||||
]),
|
||||
])
|
||||
->columnSpanFull(),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('name')
|
||||
->label(__('lab_tests.fields.name'))
|
||||
->searchable()
|
||||
->sortable(),
|
||||
|
||||
IconColumn::make('is_default')
|
||||
->label(__('lab_tests.fields.is_default'))
|
||||
->boolean(),
|
||||
|
||||
IconColumn::make('is_active')
|
||||
->label(__('lab_tests.fields.is_active'))
|
||||
->boolean(),
|
||||
|
||||
TextColumn::make('created_at')
|
||||
->label(__('lab_tests.fields.created_at'))
|
||||
->sortable(),
|
||||
])
|
||||
->defaultSort('name')
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
DeleteAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
\Filament\Actions\BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListLabTests::route('/'),
|
||||
'create' => Pages\CreateLabTest::route('/create'),
|
||||
'edit' => Pages\EditLabTest::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user