Skip to content

Commit fdfb465

Browse files
committed
fix: various intervention fixes
1 parent c842582 commit fdfb465

4 files changed

Lines changed: 20 additions & 1 deletion

File tree

app/Filament/Resources/Beneficiaries/Resources/Interventions/InterventionResource.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ class InterventionResource extends Resource
2626

2727
protected static ?string $parentResource = BeneficiaryResource::class;
2828

29+
protected static ?string $recordTitleAttribute = 'name';
30+
2931
public static function getModelLabel(): string
3032
{
3133
return __('intervention.label.singular');

app/Filament/Resources/Beneficiaries/Resources/Interventions/RelationManagers/InterventionsRelationManager.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
use Filament\Support\Icons\Heroicon;
2727
use Filament\Tables\Columns\TextColumn;
2828
use Filament\Tables\Table;
29+
use Illuminate\Database\Eloquent\Builder;
2930
use Illuminate\Database\Eloquent\Model;
3031
use Illuminate\Support\Arr;
3132
use Illuminate\Support\Facades\Auth;
@@ -120,6 +121,10 @@ public function table(Table $table): Table
120121
{
121122
return $table
122123
->recordTitleAttribute('name')
124+
->modifyQueryUsing(
125+
fn (Builder $query): Builder => $query
126+
->with('parent')
127+
)
123128
->columns([
124129
TextColumn::make('id')
125130
->label(__('field.id'))

app/Filament/Resources/Beneficiaries/Resources/Interventions/Tables/InterventionsTable.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,11 @@ public static function configure(Table $table): Table
5959
->filters([
6060
SelectFilter::make('type')
6161
->label(__('field.type'))
62-
->multiple(),
62+
->attribute('interventionable_type')
63+
->options([
64+
'case' => __('intervention.type.case'),
65+
'individual_service' => __('intervention.type.individual'),
66+
]),
6367

6468
SelectFilter::make('status')
6569
->label(__('field.status'))

app/Policies/InterventionPolicy.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ public function create(User $user): bool
4242
*/
4343
public function update(User $user, Intervention $intervention): bool
4444
{
45+
if (filled($intervention->parent_id)) {
46+
return $this->update($user, $intervention->parent);
47+
}
48+
4549
if (! $intervention->isOpen()) {
4650
return false;
4751
}
@@ -62,6 +66,10 @@ public function update(User $user, Intervention $intervention): bool
6266
*/
6367
public function delete(User $user, Intervention $intervention): bool
6468
{
69+
if (filled($intervention->parent_id)) {
70+
return $this->update($user, $intervention->parent);
71+
}
72+
6573
if (! $intervention->isOpen()) {
6674
return false;
6775
}

0 commit comments

Comments
 (0)