Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mozew's avatar
Level 6

No query results for model [App\SubmitApplication] unapproved

I am following the forum series from Jeffrey and decided to change things up a little and make my own project out of it. I have changed plenty things, such as routes and I am using tags instead of channels.

requisitions.blade.php

<form class="btn-group" action="{{ route('requisitions.unapproved', ['id' => $submitapplication->id]) }}" method="post">
    {{ method_field('PATCH') }}
    {{ csrf_field() }}
    <button type="submit" class="btn btn-danger btn-xs">UnApprover</button>
</form>

RequisitionController

public function unapproved(Request $request, $submitApplication)
{
    $submitApp = SubmitApplication::findOrFail($submitApplication);
    $submitApp->approved = 0;
    $submitApp->save();
    return redirect()->back();
}

web.php

$this->get('requisitions/unapproved', 'RequisitionController@unapproved')->name('requisitions.unapproved');

I get this error

No query results for model [App\SubmitApplication] unapproved

0 likes
6 replies
PricelessRabbit's avatar
Level 6

you pass the "id" parameter to the route: route('requisitions.unapproved', ['id' => $submitapplication->id])

so then you have to get this id from the request


public function unapproved(Request $request)
{
    $submitApp = SubmitApplication::findOrFail($request->id);
    $submitApp->approved = 0;
    $submitApp->save();
    return redirect()->back();
}

1 like
Snapey's avatar

tou need a placeholder in the route for the submitApplication id that you are trying to pass

$this->get('requisitions/unapproved/{id}', 'RequisitionController@unapproved')->name('requisitions.unapproved');

and then use id in the controller

public function unapproved(Request $request, $id)
{
    $submitApp = SubmitApplication::findOrFail($id);
    $submitApp->approved = 0;
    $submitApp->save();
    return redirect()->back();
}


Snapey's avatar

And dont forget you need to check WHO is setting the approved flag

PricelessRabbit's avatar

Moreover, you have to pay attention at the http method you are using. In the html form you send a post request, but in the routes you accept a get request.

Snapey's avatar

your route needs to be PATCH and not get

1 like

Please or to participate in this conversation.