Skip to content

Commit

Permalink
Merge pull request #228 from SamHep0803/search-by-identifier
Browse files Browse the repository at this point in the history
fix: make FIR searchable by its identifier
  • Loading branch information
daveroverts authored Aug 2, 2022
2 parents e537146 + bfbe32e commit 20b6d91
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,25 @@

namespace App\Filament\Resources\UserResource\RelationManagers;

use App\Models\FlightInformationRegion;
use Filament\Forms;
use Filament\Resources\Form;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Resources\Table;
use Filament\Tables;
use Illuminate\Support\Collection;

class FlightInformationRegionsRelationManager extends RelationManager
{
protected static string $relationship = 'flightInformationRegions';

protected static ?string $recordTitleAttribute = 'name';

private static function setFirOptions(Collection $firs)
{
return $firs->mapWithKeys(fn (FlightInformationRegion $fir) => [$fir->id => $fir->identifierName]);
}

public static function form(Form $form): Form
{
return $form
Expand Down Expand Up @@ -45,7 +52,17 @@ public static function table(Table $table): Table
])
->headerActions([
Tables\Actions\CreateAction::make(),
Tables\Actions\AttachAction::make(),
Tables\Actions\AttachAction::make()
->form(fn (Form $form): array => [
Forms\Components\Select::make('flight_information_region_id')
->label("Flight Information Region")
->searchable()
->options(
self::setFirOptions(
FlightInformationRegion::all()
)
)
])
])
->actions([
Tables\Actions\EditAction::make(),
Expand Down

0 comments on commit 20b6d91

Please sign in to comment.