F
Filament2y ago
dyo

error No query results for model in model when testing

I got above error when i tested editRecord.. Spesifically i got error "No query results for model [App\Models\Setoran]" here's my code:
$setoran = Setoran::where('lembagaId', $lembaga_id)->inRandomOrder()->first();

$data = [
'lembagaId' => $lembaga_id,
'jenis_donasi_id' => $jenis_donasi_id,
'rekening_id' => $rekening_id,
'dana' => $dana,
];
// dd($setoran->getRouteKey());

$this->actingAs($user)->livewire(EditSetoran::class, ['record' => $setoran->getRouteKey()])
->fillForm($data)->call('save')->assertHasNoFormErrors();
$setoran = Setoran::where('lembagaId', $lembaga_id)->inRandomOrder()->first();

$data = [
'lembagaId' => $lembaga_id,
'jenis_donasi_id' => $jenis_donasi_id,
'rekening_id' => $rekening_id,
'dana' => $dana,
];
// dd($setoran->getRouteKey());

$this->actingAs($user)->livewire(EditSetoran::class, ['record' => $setoran->getRouteKey()])
->fillForm($data)->call('save')->assertHasNoFormErrors();
What should i do?
2 Replies
Dan Harrin
Dan Harrin2y ago
you shouldnt need ->getRouteKey()
dyo
dyoOP2y ago
what it should be? sorry, nevermind, i've figured out..
Want results from more Discord servers?
Add your server