35 lines
959 B
PHP
35 lines
959 B
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use App\Domain\Cms\NavigationItem;
|
|
use App\Domain\Cms\NavigationItemPolicy;
|
|
use App\Domain\Cms\Page;
|
|
use App\Domain\Cms\PagePolicy;
|
|
use App\Models\User;
|
|
use App\Policies\UserPolicy;
|
|
use Illuminate\Support\Facades\Gate;
|
|
use Illuminate\Support\Facades\View;
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
{
|
|
public function register(): void
|
|
{
|
|
//
|
|
}
|
|
|
|
public function boot(): void
|
|
{
|
|
Gate::policy(Page::class, PagePolicy::class);
|
|
Gate::policy(NavigationItem::class, NavigationItemPolicy::class);
|
|
Gate::policy(User::class, UserPolicy::class);
|
|
|
|
View::composer('layouts.site', function ($view): void {
|
|
if (! array_key_exists('navigation', $view->getData())) {
|
|
$view->with('navigation', NavigationItem::query()->with('page')->orderBy('sort_order')->orderBy('id')->get());
|
|
}
|
|
});
|
|
}
|
|
}
|