phpvms/app/Http/Composers/PageLinksComposer.php
Nabeel S 45873431e4
Add public/private pages #641 (#644)
* Add public/private pages #641

* Cleanup the form requests
2020-03-28 13:03:52 -04:00

39 lines
870 B
PHP

<?php
namespace App\Http\Composers;
use App\Contracts\Composer;
use App\Repositories\PageRepository;
use Illuminate\Support\Facades\Auth;
use Illuminate\View\View;
class PageLinksComposer extends Composer
{
protected $pageRepo;
/**
* PageLinksComposer constructor.
*
* @param \App\Repositories\PageRepository $pageRepo
*/
public function __construct(PageRepository $pageRepo)
{
$this->pageRepo = $pageRepo;
}
/**
* @param \Illuminate\View\View $view
*/
public function compose(View $view)
{
// If not logged in, then only get the public pages
$w = ['enabled' => true];
if (!Auth::check()) {
$w = ['public' => true];
}
$pages = $this->pageRepo->findWhere($w, ['id', 'name', 'slug', 'icon']);
$view->with('page_links', $pages);
}
}