feat: add helpers
This commit is contained in:
@@ -0,0 +1,27 @@
|
|||||||
|
<?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 Storage::disk('public')->url($file->path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user