Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel Request not found when called within a Controller's function

I am trying to authorise the user to submit a post request, by using a Request within Laravel. The error I am getting is:

ReflectionException in RouteDependencyResolverTrait.php line 57: Class App\Http\Controllers\UpdateClinicDescriptionFormRequest does not exist

It's as if Laravel is trying to look within Controllers for the Request, but it's clearly in the Request's folder.

The UpdateClinicDescriptionFormRequest.php file is in the Request's folder.

The function trying to access to Request is:

 public function postUpdateDescription(UpdateClinicDescriptionFormRequest $request, $id)
 {
    $clinic = Clinic::find($id);

    $clinic->description = Input::get('description');
    $clinic->save();
    return redirect()->back();

}

Any help would be hugely appreciated.


1 Answers

It looks like you haven't imported it. Add this at the top of your controller, after the namespace declaration:

use App\Http\Requests\UpdateClinicDescriptionFormRequest;

And make sure that file is properly namespaced:

namespace App\Http\Requests;
like image 92
Joel Hinz Avatar answered May 07 '26 15:05

Joel Hinz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!