F
Filament11mo ago
Augadh

create route not working(404) in all resources. HELP!

whenever i try to go to create route on any resource I get a 404 error, debugbar shows an exception
No query results for model [App\Models\Service] create
E:\dev\daksha-property\vendor\filament\filament\src\Resources\Pages\Concerns\InteractsWithRecord.php#21
Illuminate\Database\Eloquent\ModelNotFoundException
$record = static::getResource()::resolveRecordRouteBinding($key);

if ($record === null) {
throw (new ModelNotFoundException())->setModel($this->getModel(), [$key]);
}

return $record;
No query results for model [App\Models\Service] create
E:\dev\daksha-property\vendor\filament\filament\src\Resources\Pages\Concerns\InteractsWithRecord.php#21
Illuminate\Database\Eloquent\ModelNotFoundException
$record = static::getResource()::resolveRecordRouteBinding($key);

if ($record === null) {
throw (new ModelNotFoundException())->setModel($this->getModel(), [$key]);
}

return $record;
it worked previously the only change i made recently was to add view to all resources
No description
8 Replies
ZedoX
ZedoX11mo ago
Why is it trying to resolve record in create? Did you extend your Create page from CreateRecord?
Augadh
Augadh11mo ago
no
Augadh
Augadh11mo ago
query error
No description
ZedoX
ZedoX11mo ago
Please share your Create page code
Augadh
Augadh11mo ago
<?php

namespace App\Filament\Admin\Resources\ServiceResource\Pages;

use App\Filament\Admin\Resources\ServiceResource;
use Filament\Actions;
use Filament\Resources\Pages\CreateRecord;

class CreateService extends CreateRecord
{
protected static string $resource = ServiceResource::class;
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('index');
}
}
<?php

namespace App\Filament\Admin\Resources\ServiceResource\Pages;

use App\Filament\Admin\Resources\ServiceResource;
use Filament\Actions;
use Filament\Resources\Pages\CreateRecord;

class CreateService extends CreateRecord
{
protected static string $resource = ServiceResource::class;
protected function getRedirectUrl(): string
{
return $this->getResource()::getUrl('index');
}
}
ZedoX
ZedoX11mo ago
Oh wait I think I know what's wrong, it's hitting the view route instead of create @augadh in your Resource on getPages method, make sure your create route is above the view route
Augadh
Augadh11mo ago
@z3d0x Okay that fixed it weird issue though Thanks a lot
Dennis Koch
Dennis Koch11mo ago
Not weird at all. The order matters. The view route has a $record param and is trying to load record with ID create then.