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
ZedoX2y ago
Why is it trying to resolve record in create? Did you extend your Create page from CreateRecord?
Augadh
AugadhOP2y ago
no
Augadh
AugadhOP2y ago
query error
No description
ZedoX
ZedoX2y ago
Please share your Create page code
Augadh
AugadhOP2y 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
ZedoX2y 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
AugadhOP2y ago
@z3d0x Okay that fixed it weird issue though Thanks a lot
Dennis Koch
Dennis Koch2y 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.

Did you find this page helpful?