Files
sogandAsghary.Project09/app/helpers/helpers.php
T
2026-08-19 15:44:01 -07:00

59 lines
1.4 KiB
PHP

<?php
if (!function_exists('getUserFullName')) {
function getUserFullName(?\App\Models\User $user = null): string
{
if (!$user) {
$user = auth()->user();
}
return $user->first_name . ' ' . $user->last_name;
}
}
if (!function_exists('getFileUrl')) {
function getFileUrl(?int $fileId): ?string
{
if (!$fileId){
return null;
}
$file = \App\Models\File::find($fileId);
if (!$file) {
return null;
}
return asset('storage/' . $file->path);
}
if (!function_exists('activeAccountSidebar')) {
function activeAccountSidebar(string $routeName): string
{
if (\Illuminate\Support\Facades\Route:: currentRouteName() == $routeName) {
return 'bg-blue-500/10 text-blue-500';
}
return 'hover:text-blue-500';
}
}
if (!function_exists('activeAdminSidebar')) {
function activeAdminSidebar(string|array $routeNames): string
{
$currentRouteName = \Illuminate\Support\Facades\Route::currentRouteName();
if (is_string($routeNames)) {
$routeNames = [$routeNames];
}
if (in_array($currentRouteName, $routeNames)) {
return 'active';
}
return '';
}
}
}