F
Filament15mo 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
ZedoX15mo ago
Why is it trying to resolve record in create? Did you extend your Create page from CreateRecord?
Augadh
AugadhOP15mo ago
no
Augadh
AugadhOP15mo ago
query error
No description
ZedoX
ZedoX15mo ago
Please share your Create page code
Augadh
AugadhOP15mo 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
ZedoX15mo 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
AugadhOP15mo ago
@z3d0x Okay that fixed it weird issue though Thanks a lot
Dennis Koch
Dennis Koch15mo 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.
Want results from more Discord servers?
Add your server