#laravel
#ларавель
Вопрос:
Я использую этот маршрут для получения общих экземпляров для всех моих маршрутов :
View::composer('*', 'AppHttpControllersMaster@all');
И в моем контроллере
public function all($view){
$general = General::where('id',1)->first();
$footer = Footer::where('id',1)->first();
$navmenu = Navmenu::with('submenus')->where('status',1)->get();
$socials = Social::where('status',1)->get();
$categories = Category::where('status',1)->get();
$footer_about = FooterLinkAbout::where('status',1)->take(5)->get();
$footer_explore = FooterLinkExplore::where('status',1)->take(5)->get();
$footer_cat = Footer_link_category::where('status',1)->take(5)->get();
$fund_raised = Transection::all();
$languages = Language::where('status',1)->get();
$ip = '43.250.81.202';
$arr_ip = geoip()->getLocation($ip);
$user_location = $arr_ip->country; // get a country
// $main_currency = Currency::where('status',1)->get();
$currencies = Currency::where('status',1)-
>where('session_currency','!=',Session::get('currency_c'))->get();
$user_currency = Currency::where('session_currency',Session::get('currency_c'))->first();
$currency_by_location = Currency::where('status',1)->where('country_name',$user_location)-
>first();
$view->with('general',$general)->with('footer',$footer)->with('navmenu',$navmenu)-
>with('socials',$socials)->with('categories',$categories)->with('footer_about',$footer_about)-
>with('footer_explore',$footer_explore)->with('footer_cat',$footer_cat)-
>with('languages',$languages)->with('currencies',$currencies)-
>with('user_currency',$user_currency)->with('currency_by_location',$currency_by_location)-
>with('fund_raised',$fund_raised);
}
Но после очистки маршрутов с использованием следующих кодов :
php artisan cache:clear
php artisan route:cache
php artisan config:cache
Я получаю следующую ошибку :
Комментарии:
1. Что произойдет, если вы переключитесь на это? Вы видите ожидаемые данные? Это хорошая отправная точка для отладки проблемы, начиная с понимания того, выполняется ли этот код вообще. общедоступная функция all($view){ $categories = Category::where(‘status’,1)->get(); dd($categories); }
2. Это выдает ту же ошибку, код не выполняется, я думаю
3. могу ли я использовать несколько view::composer?