diff --git a/app/Helpers/functions.php b/app/Helpers/functions.php index 5986646..5af7003 100644 --- a/app/Helpers/functions.php +++ b/app/Helpers/functions.php @@ -1,31 +1,40 @@ = 1073741824) - { - $bytes = number_format($bytes / 1073741824, 2) . ' GB'; - } - elseif ($bytes >= 1048576) - { - $bytes = number_format($bytes / 1048576, 2) . ' MB'; - } - elseif ($bytes >= 1024) - { - $bytes = number_format($bytes / 1024, 2) . ' KB'; - } - elseif ($bytes > 1) - { - $bytes = $bytes . ' bytes'; - } - elseif ($bytes == 1) - { - $bytes = $bytes . ' byte'; - } - else - { + if ($bytes >= 1073741824) { + $bytes = number_format($bytes / 1073741824, 2).' GB'; + } elseif ($bytes >= 1048576) { + $bytes = number_format($bytes / 1048576, 2).' MB'; + } elseif ($bytes >= 1024) { + $bytes = number_format($bytes / 1024, 2).' KB'; + } elseif ($bytes > 1) { + $bytes = $bytes.' bytes'; + } elseif ($bytes == 1) { + $bytes = $bytes.' byte'; + } else { $bytes = '0 bytes'; } return $bytes; -} \ No newline at end of file +} + +function userPhoto(User $user, $attributes = []) +{ + return Html::image( + userPhotoPath($user->photo_path, $user->gender_id), + null, + $attributes + ); +} + +function userPhotoPath($photoPath, $genderId) +{ + if (is_file(public_path('storage/'.$photoPath))) { + return asset('storage/'.$photoPath); + } + + return asset('images/icon_user_'.$genderId.'.png'); +} diff --git a/resources/views/users/edit.blade.php b/resources/views/users/edit.blade.php index 19c1af2..22f39c9 100644 --- a/resources/views/users/edit.blade.php +++ b/resources/views/users/edit.blade.php @@ -13,13 +13,6 @@