Answer the question
In order to leave comments, you need to log in
What to put in the controller and what in the model?
Good afternoon everyone, I'm trying to understand OOP and using Laravel as an MVC framework and I can't figure out how to separate functions - what is done in the controller and what is in the model. That is why I have a number of questions.
For example, I have a class with attributes
id
name
age
$model = new MyModel();
$data = $model->findOrFail($id);
$this->name = $data->name;
$this->age = $data->age;
return $this;
Answer the question
In order to leave comments, you need to log in
1. Take this course: https://laracasts.com/series/laravel-from-scratch-2017 - free
2. Read the documentation for things you don't understand. There for a maximum of a week if you sit in the evenings. I think an understanding of what to put where to appear.
3. If you like the course, then there is a very high-quality and voluminous one - Lets build a forum with laravel and TDD (I'm checking it myself now, creating everything in parallel on my own), or a lot of interesting ones in php / laravel, incl. and OOP. (In general, they are inexpensive, but there are also on the rutracker / courtehunters).
Of course, I myself am not a guru, but from my own experience I will say that without practice you cannot understand such things :)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question