Session not available in query scope
Hi there,
I've created a new project with Laravel 5.2. I created a query scope to determine if a user belongs to a websiteID. For my routes I used Route binding and restfull resources. So I ended up with following code in my routes file.
Route::bind('pages', function($id) {
return \App\Page::website()->findOrFail($id);
});
Route::resource('pages', 'PagesController', [
'except' => ['show']
]);
and the query scope itself is like:
public function scopeWebsite($query)
{
return $query->where('website_id', session()->get('website_id'));
}
It works with some routes like the pages.index route, but in the pages.edit route the session is not set.
I know it have to do with the 'web' middleware group. Because when I move the Session middleware to the global stack it works like it did in L 5.1.
But I want to understand why the session is not available when I use the pages.edit route.
Can anybody explain? Thanks!
Please or to participate in this conversation.