38 lines
889 B
PHP
38 lines
889 B
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use App\Models\Tenant;
|
|
use App\Models\User;
|
|
use App\Resources\UserResource;
|
|
use Inertia\Inertia;
|
|
use Inertia\Response;
|
|
|
|
final class InertiaProvider
|
|
{
|
|
private string $vueFile;
|
|
private array $props;
|
|
|
|
private ?User $user;
|
|
|
|
public function __construct(string $vueFile, array $props) {
|
|
$this->user = auth()->user();
|
|
$this->vueFile = $vueFile;
|
|
$this->props = $props;
|
|
}
|
|
|
|
public function render() : Response {
|
|
if (null !== session()->get('message')) {
|
|
$this->props['message'] = session()->get('message');
|
|
session()->forget('message');
|
|
}
|
|
|
|
$this->props['availableLocalGroups'] = Tenant::where(['is_active_local_group' => true])->get();
|
|
|
|
return Inertia::render(
|
|
str_replace('/', '/Views/', $this->vueFile),
|
|
$this->props
|
|
);
|
|
}
|
|
}
|