FilamentF
Filament2y ago
Sven

Only allow to edit one record in my resource

Hey!

Is it possible to have a filament ressource but skip the view which lists all records and always navigate to the edit-route of a specific record?

I tried something like this:

// ProfileResource.php

    public static function getPages(): array
    {
        return [
            // I named it index so that it is still
            // in the navigation
            'index' => Pages\EditProfile::route('/'),
        ];
    }

// ProfileResourse/Pages/EditProfile.php
class EditProfile extends EditRecord
{
    protected static string $resource = ProfileResource::class;

    // I am doing this so the route can be visited without
    // providing the ID to the URL
    public function mount(): void
    {
        $this->record = $this->resolveRecord(auth()->user()->profile());

        $this->authorizeAccess();

        $this->fillForm();

        $this->previousUrl = url()->previous();
    }


This approach can not work because i am overloading mount with the wrong number of arguments.
Was this page helpful?