phpvms/app/Http/Composers/PageLinksComposer.php
Nabeel S 82b873c071
Domain detection failing for .co.uk, etc #647 (#648)
* Fix domain name detection #647

* Ignore page links check if no DB configured #641
2020-03-28 19:07:46 -04:00

45 lines
992 B
PHP

<?php
namespace App\Http\Composers;
use App\Contracts\Composer;
use App\Repositories\PageRepository;
use Exception;
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)
{
try {
// 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']);
} catch (Exception $e) {
$pages = [];
}
$view->with('page_links', $pages);
}
}