0

I'm trying to work on my model using Laravel.

Table name: refregions

Model: app/Refregion

Controller: in one of my function I have this code:

$regions = Refregion::all();

And I defined the model on controller

use app\Refregion;

Can someone tell me why class cannot be found?

Thank you.

2 Answers 2

2

Because you are using the wrong path of Model in your controller. you have to use the following one instant of this one 'use app\Refregion;'.

use App\Refregion;
Sign up to request clarification or add additional context in comments.

Comments

1

In your Controller you have to use like this below

use App\Refregion;

Or

use \App\Refregion;

5 Comments

Why \App also a way?
@vivek_23 Yes. You can also use that way
\App would make it look into global namespace I presume App is autoloaded from composer. Since, we don't have any collisions, I think App\Refregion is fine.
@vivek_23 I agree with you. Even use app\ Refregion; also works.
Thanks A.A vivek I found it a while ago. Your solutions are right. Thanks you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.