Laravel,将用户ID传递给控制器

So I am fairly new to laravel, a php framework. I am creating a community based website. So I just had general questions and trying to find if my practices are right.

So through research, correct me if I'm wrong,

  • The controller retrieves all the data from the model. (Does this mean that all the info must be pulled in the model and then sent to the controller? Or does it mean that now that I have created a model, I can use eloquent in the controller?)

I have also encountered a problem, I've created a login system and logout system for my website. Though, Auth::user(), a way to identify if a session has been set for a user, only works in the route and the views. But when I do Auth:user() in the controller, it always returns false? Why so?

I am a beginner in laravel, and please don't crucify me if you don't find these as the best questions. I have already done research before posting this question.

Thanks

As long as you follow the Laravel naming conversion, you'll have automatic access to your database through Eloquent. Otherwise, you'll have to configure Eloquent yourself, which you can do if you choose to.

For a start, your database table should be the plural of you model name.
For example, if your table was named users, your model would be User.
You would then have access the User model in your controller via User::eloquentMethodHere

For more help with the Auth class, you can have a look at the docs or post some code for further assistance.