mirror of https://github.com/Lukibeg/OmniBoard.git
48 lines
1.1 KiB
PHP
48 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Inertia\Middleware;
|
|
use App\Models\Tenant;
|
|
|
|
class HandleInertiaRequests extends Middleware
|
|
{
|
|
/**
|
|
* The root template that is loaded on the first page visit.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $rootView = 'app';
|
|
|
|
/**
|
|
* Determine the current asset version.
|
|
*/
|
|
public function version(Request $request): ?string
|
|
{
|
|
return parent::version($request);
|
|
}
|
|
|
|
/**
|
|
* Define the props that are shared by default.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function share(Request $request): array
|
|
{
|
|
return [
|
|
...parent::share($request),
|
|
'auth' => [
|
|
'user' => $request->user(),
|
|
],
|
|
|
|
'tenants' => function () use ($request) {
|
|
if ($request->user() && $request->user()->role === 'admin') {
|
|
return Tenant::select('id', 'name')->orderBy('name')->get();
|
|
}
|
|
return [];
|
|
},
|
|
];
|
|
}
|
|
}
|