I was wondering if anyone can provide any wisdom of how to accomplish page visibility within my app? In the database I am storing `visiblity` which is either `"public"` or `"private"`

So, if the page is private, the user would need to be logged in to see the page, but if the page is public, then anyone can view the page. Below are snippets of my route and controller.

**routes/web.php**

```
Route::get('/{slug}', '\App\Http\Controllers\Frontend\FrontendPagesController@page');

```

**Page method in FrontendPagesController**

```
public function page($slug){
    $page = Page::where('slug',$slug)->where('active',1)->get()->first();
    if(is_null($page)){
        return abort(404);
    }
    $this->data['page'] = $page;
    return view('pages.page',$this->data);
}

```

The route currently isn't using any middleware. My first thought was to assign it a middleware that would query the database when it hits this route (to force authentication if it was private), but I didn't want to query the database twice. Is there a way to pass the results of this said middleware to the controller, or does anyone have any other suggestion on how to accomplish this issue?