Answer the question
In order to leave comments, you need to log in
How to write under MVC on laravel example?
I can’t figure out how to write under MVC correctly, in particular, problems with understanding what to shove into the controller and what into the model, with the view it’s more or less clear, please tell me using my example because I’ve already read the theory.
So there is a news parser, at the moment it looks like this: I
created a model in App, I created a function in it (the code is large, so I’ll just write it in blocks 1-2-3-4-5)
public static function pars() {
1) Парсим страницу + распарсиваем нужные данные. На выходе имеем массив спарсинных данных для вставки в бд.
2) Сверяемся с базой на наличие дублей и формируем новый массив для вставки без дублей. На выходе имеем массив уникальных новостей.
3) Далее идет вставка этого массива в бд
4) После поступления новых данных, идет кое какая проверка по новым новостям на основании которой, удаляются некоторые старые.
5) Затем идет выборка по определенным критериям из этих новостей и отправка мне смс, если такие есть
return;
}
Route::get('/pars', function () {
App\News::pars();
return ;
});
Answer the question
In order to leave comments, you need to log in
At the output, I have a site / pars parser that is screwed onto the cron and everything is ready.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question