Answer the question
In order to leave comments, you need to log in
How to use methods of any of your created models in laravel 5 in the service provider class?
I am trying to create a view composer. To do this, I create my own service provider, connect it - everything is according to the instructions.
And inside the boot method I create a composer
view()->composer('lalalala', function($view) {
});
use App\News;
view()->composer('lalalala', function($view) {
$new = new News; // создаю объект класса News
$data = $news -> getNews(); // получаю список новостей
$view ->with('news', $data); // передаю во вьюшку
});
public function boot(News $new)
{
view()->composer('lalalala', function($view) {
$new = new News; // создаю объект класса News
$data = $news -> getNews(); // получаю список новостей
$view ->with('news', $data); // передаю во вьюшку
});
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question