Skip to content

Commit

Permalink
Fixes the select dependencies issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
suhaimim committed Dec 16, 2023
1 parent 113333c commit 3cb6c8c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 17 deletions.
12 changes: 7 additions & 5 deletions app/Filament/Resources/AhliKariahResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@

namespace App\Filament\Resources;

// use App\Filament\Resources\NegeriResource;
use App\Filament\Resources\AhliKariahResource\Pages;
use App\Filament\Resources\AhliKariahResource\RelationManagers;
use App\Models\Negeri;
use App\Models\Bandar;
use App\Models\AhliKariah;
use Filament\Forms;
use Filament\Forms\Form;
Expand Down Expand Up @@ -45,16 +48,15 @@ public static function form(Form $form): Form
->pluck('name', 'id'))
->searchable()
// ->preload()
// ->live()
->live()
->required(),
Forms\Components\Select::make('bandar_id')
->label('Nama Bandar')
// ->options(fn(Get $get): Collection => Bandar::query()
// ->where('negeri_id', $get('negeri_id'))
// ->pluck('name', 'id'))
->options(fn(Get $get): Collection => Bandar::query()
->where('negeri_id', $get('negeri_id'))
->pluck('name', 'id'))
->searchable()
// ->preload()
->live()
->required(),
Forms\Components\TextInput::make('name_penuh')
->required()
Expand Down
35 changes: 23 additions & 12 deletions app/Filament/Resources/TanggunganResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@

use App\Filament\Resources\TanggunganResource\Pages;
use App\Filament\Resources\TanggunganResource\RelationManagers;
use App\Models\Negeri;
use App\Models\Bandar;
use App\Models\Tanggungan;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Forms\Get;
use Filament\Forms\Components\Select;
use Filament\Resources\Resource;
use Illuminate\Support\Collection;
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Support\HtmlString;
Expand All @@ -29,22 +34,28 @@ public static function form(Form $form): Form
return $form
->schema([
Forms\Components\Select::make('negara_id')
->label('Nama Negara')
->relationship(name: 'negara', titleAttribute: 'name')
->searchable()
// ->preload()
->required(),
->label('Nama Negara')
->relationship(name: 'negara', titleAttribute: 'name')
->searchable()
// ->preload()
->live()
->required(),
Forms\Components\Select::make('negeri_id')
->label('Nama Negeri')
->relationship(name: 'negeri', titleAttribute: 'name')
->options(fn(Get $get): Collection => Negeri::query()
->where('negara_id', $get('negara_id'))
->pluck('name', 'id'))
->searchable()
// ->preload()
// ->preload()
->live()
->required(),
Forms\Components\Select::make('bandar_id')
->label('Nama Bandar')
->relationship(name: 'bandar', titleAttribute: 'name')
->options(fn(Get $get): Collection => Bandar::query()
->where('negeri_id', $get('negeri_id'))
->pluck('name', 'id'))
->searchable()
// ->preload()
// ->preload()
->required(),
Forms\Components\Select::make('ahli_kariah_id')
->label('NRIC Penjaga')
Expand Down Expand Up @@ -134,9 +145,9 @@ public static function getPages(): array
{
return [
'index' => Pages\ListTanggungans::route('/'),
'create' => Pages\CreateTanggungan::route('/create'),
'view' => Pages\ViewTanggungan::route('/{record}'),
'edit' => Pages\EditTanggungan::route('/{record}/edit'),
// 'create' => Pages\CreateTanggungan::route('/create'),
// 'view' => Pages\ViewTanggungan::route('/{record}'),
// 'edit' => Pages\EditTanggungan::route('/{record}/edit'),
];
}
}

0 comments on commit 3cb6c8c

Please sign in to comment.