Files

50 lines
1.8 KiB
PHP

<?php
namespace App\Http\Controllers\Concerns;
use Illuminate\Http\Request;
trait BuildsPortalProps
{
/**
* @return array<string, mixed>
*/
protected function portalProps(Request $request): array
{
$user = $request->user();
return [
'site' => [
'name' => config('moonwell.realm.server_name'),
'tagline' => config('moonwell.realm.tagline'),
],
'auth' => [
'authenticated' => $user !== null,
'username' => $user?->username,
'access_label' => $user?->accessLabel(),
'is_admin' => $user?->canAccessAdminPanel() ?? false,
],
'urls' => [
'home' => route('landing.index'),
'news' => route('news.index'),
'login' => route('login'),
'cabinet' => route('cabinet.index'),
'admin' => route('admin.accounts.index'),
'logout' => route('logout'),
'offer' => config('moonwell.legal.offer_published') ? route('legal.offer') : null,
'privacy' => config('moonwell.legal.privacy_published') ? route('legal.privacy') : null,
'rules' => config('moonwell.legal.rules_published') ? route('legal.rules') : null,
'admin_accounts' => route('admin.accounts.index'),
'admin_balances' => route('admin.balances.index'),
'admin_shop' => route('admin.shop.index'),
'admin_news' => route('admin.news.index'),
'admin_login_news' => route('admin.login-screen-news.index'),
],
'flash' => [
'status' => $request->session()->get('status'),
'error' => $request->session()->get('error'),
],
];
}
}