У меня есть глобальный __construct()
функции внутри моего basecontroller, что выглядит так:Laravel возвращает ошибку, когда объект существует
public function __construct() {
$alerts = Alert::orderBy('id', 'DESC')->whereNull('deleted_at')->get();
return View::share('alert', $alerts);
}
Это работает на каждой странице, кроме как на 2-х страницах ...
Моего маршрута выглядит следующим образом:
Route::resource('/', 'WebsiteController');
Route::get('nieuws/{id}', '[email protected]');
Route::resource('login', 'LoginController');
Route::resource('auth', '[email protected]');
Route::resource('logout', '[email protected]');
Route::resource('foto', 'PictureController');
Route::resource('studio', '[email protected]');
//special routing for the mirrors
Route::get('spiegels', '[email protected]');
Route::get('spiegels/{dirName}', '[email protected]');
//end of special routing
Route::resource('calendar', 'CalendarController');
Route::get('history', function()
{
return View::make('home.history');
});
Route::get('publicity', function()
{
return View::make('home.publicity');
});
страницы, которые не работают, являются следующие:
- публичность
- история
Ошибка я получаю Undefined variable: alert
но это странно, потому что внутри мой взгляд, у меня есть это:
@foreach($alert as $alert)
<div class="alert alert-{{ $alert->type }}" role="alert" style="margin-bottom:-10px;">{{ $alert->message }}</div>
@endforeach
А на всех остальных страницах она работает.
Что я не так?
Как мне это сделать? – Robin
Решенный! Спасибо! – Robin
Хорошо. Спасибо ... извините, набрав решение :) –