65 lines
2.1 KiB
PHP
65 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\RegistrationResource\RelationManagers;
|
|
|
|
use Filament\Forms;
|
|
use Filament\Tables;
|
|
use Filament\Forms\Form;
|
|
use App\Models\Treatment;
|
|
use Filament\Tables\Table;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
|
use Filament\Resources\RelationManagers\RelationManager;
|
|
|
|
class PatientTreatmentsRelationManager extends RelationManager
|
|
{
|
|
protected static string $relationship = 'patientTreatments';
|
|
// protected static string $recordTitleAttribute = 'id';
|
|
|
|
public function form(Form $form): Form
|
|
{
|
|
return $form
|
|
->schema([
|
|
Forms\Components\Select::make('treatment_id')
|
|
->options(Treatment::all()->pluck('name', 'id'))
|
|
->label('Treatment')
|
|
->required(),
|
|
Forms\Components\TextInput::make('quantity')
|
|
->numeric()
|
|
->default(1)
|
|
->label('Quantity'),
|
|
]);
|
|
}
|
|
|
|
public function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->recordTitleAttribute('treatment_id')
|
|
->columns([
|
|
Tables\Columns\TextColumn::make('no')
|
|
->label('No.')
|
|
->getStateUsing(function ($rowLoop, $record) {
|
|
return $rowLoop->iteration;
|
|
}),
|
|
Tables\Columns\TextColumn::make('treatment.name')->label('Treatment'),
|
|
Tables\Columns\TextColumn::make('treatment.cost')->label('Treatment'),
|
|
Tables\Columns\TextColumn::make('quantity')->label('Quantity'),
|
|
])
|
|
->filters([
|
|
//
|
|
])
|
|
->headerActions([
|
|
Tables\Actions\CreateAction::make(),
|
|
])
|
|
->actions([
|
|
Tables\Actions\EditAction::make(),
|
|
Tables\Actions\DeleteAction::make(),
|
|
])
|
|
->bulkActions([
|
|
Tables\Actions\BulkActionGroup::make([
|
|
Tables\Actions\DeleteBulkAction::make(),
|
|
]),
|
|
]);
|
|
}
|
|
}
|