caweren
caweren
FFilament
Created by caweren on 7/19/2023 in #❓┊help
Missing route parameter when editing resource
Yeah, that's what i ended up with. The missing route parameter was due to id not being in the $fillable array, so it got stripped from the request before livewire tried to solve the route. However, the model is not getting saved now - I'll make a new thread for this. Thank your for helping out, marking as solved.
17 replies
FFilament
Created by caweren on 7/19/2023 in #❓┊help
Missing route parameter when editing resource
Also, looking through the request sent to Livewire when i click "save changed", i can see license_id and license. license_id is unchanged from the database value, while license has the new, updated value (this ofcourse won't get saved, since license is not a column in my database). Is it possible, on a select with relationship, to manually put in the column name?
17 replies
FFilament
Created by caweren on 7/19/2023 in #❓┊help
Missing route parameter when editing resource
Sorry about the delay, had lunch 🙂 So, testing a little further - if i add id to $fillable on the Tenant model, the error goes away and i get the notification that the settings has been saved! However, the changes are not saved.
17 replies
FFilament
Created by caweren on 7/19/2023 in #❓┊help
Missing route parameter when editing resource
I had not, no. I just added both, didn't change anything 😦
17 replies
FFilament
Created by caweren on 7/19/2023 in #❓┊help
Missing route parameter when editing resource
Thanks for trying though 🙂
17 replies
FFilament
Created by caweren on 7/19/2023 in #❓┊help
Missing route parameter when editing resource
2.17.50
17 replies
FFilament
Created by caweren on 7/19/2023 in #❓┊help
Missing route parameter when editing resource
Sure, here:
<?php

namespace App\Filament\Resources;

use App\Filament\Resources\TenantResource\Pages;
use App\Models\Tenant;
use Filament\Forms;
use Filament\Resources\Form;
use Filament\Resources\Resource;
use Filament\Resources\Table;
use Filament\Tables;

class TenantResource extends Resource
{
protected static ?string $model = Tenant::class;

protected static ?string $navigationIcon = 'heroicon-o-users';

public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\TextInput::make('id')
->required()
->maxLength(255),
Forms\Components\Select::make('License')
->relationship('license', 'name')
->default('1')
->required()
]);
}

public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('id'),
Tables\Columns\TextColumn::make('license.name'),
Tables\Columns\TextColumn::make('Seats used')
->getStateUsing(function (Tenant $record) {
return "{$record->license->tenants->count()} / {$record->license->seats}";
})
])
->filters([
//
])
->actions([
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\DeleteBulkAction::make(),
]);
}

public static function getRelations(): array
{
return [
//
];
}

public static function getPages(): array
{
return [
'index' => Pages\ListTenants::route('/'),
'create' => Pages\CreateTenant::route('/create'),
'edit' => Pages\EditTenant::route('/{record}/edit'),
];
}
}
<?php

namespace App\Filament\Resources;

use App\Filament\Resources\TenantResource\Pages;
use App\Models\Tenant;
use Filament\Forms;
use Filament\Resources\Form;
use Filament\Resources\Resource;
use Filament\Resources\Table;
use Filament\Tables;

class TenantResource extends Resource
{
protected static ?string $model = Tenant::class;

protected static ?string $navigationIcon = 'heroicon-o-users';

public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\TextInput::make('id')
->required()
->maxLength(255),
Forms\Components\Select::make('License')
->relationship('license', 'name')
->default('1')
->required()
]);
}

public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('id'),
Tables\Columns\TextColumn::make('license.name'),
Tables\Columns\TextColumn::make('Seats used')
->getStateUsing(function (Tenant $record) {
return "{$record->license->tenants->count()} / {$record->license->seats}";
})
])
->filters([
//
])
->actions([
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\DeleteBulkAction::make(),
]);
}

public static function getRelations(): array
{
return [
//
];
}

public static function getPages(): array
{
return [
'index' => Pages\ListTenants::route('/'),
'create' => Pages\CreateTenant::route('/create'),
'edit' => Pages\EditTenant::route('/{record}/edit'),
];
}
}
17 replies
FFilament
Created by caweren on 7/19/2023 in #❓┊help
Missing route parameter when editing resource
the edit page is the default one that gets generated with php artisan make:filament-resource TenantResource --generate:
<?php

namespace App\Filament\Resources\TenantResource\Pages;

use App\Filament\Resources\TenantResource;
use Filament\Pages\Actions;
use Filament\Resources\Pages\EditRecord;

class EditTenant extends EditRecord
{
protected static string $resource = TenantResource::class;

protected function getActions(): array
{
return [
Actions\DeleteAction::make(),
];
}
}
<?php

namespace App\Filament\Resources\TenantResource\Pages;

use App\Filament\Resources\TenantResource;
use Filament\Pages\Actions;
use Filament\Resources\Pages\EditRecord;

class EditTenant extends EditRecord
{
protected static string $resource = TenantResource::class;

protected function getActions(): array
{
return [
Actions\DeleteAction::make(),
];
}
}
17 replies