mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-07-11 01:24:46 +02:00
58 lines
1.2 KiB
PHP
58 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Events;
|
|
|
|
use App\Concerns\Models\HasLabel;
|
|
use App\Contracts\Models\Nameable;
|
|
use App\Models\Auth\User;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
/**
|
|
* @template TModel of \Illuminate\Database\Eloquent\Model
|
|
*/
|
|
abstract class BaseEvent
|
|
{
|
|
use HasLabel;
|
|
|
|
protected ?User $authenticatedUser;
|
|
|
|
/**
|
|
* @param TModel&Nameable $model
|
|
*/
|
|
public function __construct(protected Model&Nameable $model)
|
|
{
|
|
$this->authenticatedUser = Auth::user();
|
|
}
|
|
|
|
/** @return TModel&Nameable */
|
|
public function getModel(): Model&Nameable
|
|
{
|
|
return $this->model;
|
|
}
|
|
|
|
protected function getAuthenticatedUser(): ?User
|
|
{
|
|
return $this->authenticatedUser;
|
|
}
|
|
|
|
/**
|
|
* @return array<string, array<string, string>>
|
|
*/
|
|
protected function getUserFooter(): array
|
|
{
|
|
if (is_null($this->getAuthenticatedUser())) {
|
|
return [];
|
|
}
|
|
|
|
return [
|
|
'footer' => [
|
|
'text' => $this->getAuthenticatedUser()->getName(),
|
|
'icon_url' => $this->getAuthenticatedUser()->getFilamentAvatarUrl(),
|
|
],
|
|
];
|
|
}
|
|
}
|