#90 - cr fixes

This commit is contained in:
Adrian Hopek 2022-04-14 11:37:07 +02:00
parent 4059b101f5
commit 1129f1ebc6
12 changed files with 24 additions and 15 deletions

View File

@ -17,6 +17,16 @@ class ExceptionHandler extends Handler
"password_confirmation", "password_confirmation",
]; ];
protected array $handleByInertia = [
Response::HTTP_INTERNAL_SERVER_ERROR,
Response::HTTP_SERVICE_UNAVAILABLE,
Response::HTTP_TOO_MANY_REQUESTS,
419, // CSRF
Response::HTTP_NOT_FOUND,
Response::HTTP_FORBIDDEN,
Response::HTTP_UNAUTHORIZED,
];
public function render($request, Throwable $e): Response public function render($request, Throwable $e): Response
{ {
$response = parent::render($request, $e); $response = parent::render($request, $e);
@ -25,11 +35,11 @@ class ExceptionHandler extends Handler
return $response; return $response;
} }
if ($response->status() === 405) { if ($response->status() === Response::HTTP_METHOD_NOT_ALLOWED) {
$response->setStatusCode(404); $response->setStatusCode(Response::HTTP_NOT_FOUND);
} }
if (in_array($response->status(), [500, 503, 429, 419, 404, 403, 401], true)) { if (in_array($response->status(), $this->handleByInertia, true)) {
return Inertia::render("Error", [ return Inertia::render("Error", [
"status" => $response->status(), "status" => $response->status(),
]) ])

View File

@ -92,7 +92,7 @@ class VacationRequestCreatedNotification extends Notification
return __("The vacation request :title has been created correctly by user :creator on your behalf in the :appName.", [ return __("The vacation request :title has been created correctly by user :creator on your behalf in the :appName.", [
"title" => $this->vacationRequest->name, "title" => $this->vacationRequest->name,
"appName" => $appName, "appName" => $appName,
"creator" => $this->vacationRequest->creator->profile->fullName, "creator" => $this->vacationRequest->creator->profile->full_name,
]); ]);
} }
} }

View File

@ -49,7 +49,7 @@ class VacationRequestStatusChangedNotification extends Notification
$from = $this->vacationRequest->from->toDisplayString(); $from = $this->vacationRequest->from->toDisplayString();
$to = $this->vacationRequest->to->toDisplayString(); $to = $this->vacationRequest->to->toDisplayString();
$days = $this->vacationRequest->vacations()->count(); $days = $this->vacationRequest->vacations()->count();
$requester = $this->vacationRequest->user->profile->fullName; $requester = $this->vacationRequest->user->profile->full_name;
return (new MailMessage()) return (new MailMessage())
->greeting(__("Hi :user!", [ ->greeting(__("Hi :user!", [

View File

@ -84,7 +84,7 @@ class VacationRequestWaitsForApprovalNotification extends Notification
protected function buildDescription(): string protected function buildDescription(): string
{ {
$title = $this->vacationRequest->name; $title = $this->vacationRequest->name;
$requester = $this->vacationRequest->user->profile->fullName; $requester = $this->vacationRequest->user->profile->full_name;
if ($this->vacationRequest->state->equals(WaitingForTechnical::class)) { if ($this->vacationRequest->state->equals(WaitingForTechnical::class)) {
return __("The vacation request :title from user :requester is waiting for your technical approval.", [ return __("The vacation request :title from user :requester is waiting for your technical approval.", [

View File

@ -46,7 +46,7 @@ class TimesheetPerUserSheet implements WithTitle, WithHeadings, WithEvents, With
public function title(): string public function title(): string
{ {
return $this->user->profile->fullName; return $this->user->profile->full_name;
} }
public function headings(): array public function headings(): array

View File

@ -42,11 +42,11 @@ class Profile extends Model
public function getAvatar(): string public function getAvatar(): string
{ {
return $this->getAvatarGenerator() return $this->getAvatarGenerator()
->backgroundColor(ColorGenerator::generate($this->fullName)) ->backgroundColor(ColorGenerator::generate($this->full_name))
->image(); ->image();
} }
public function getFullNameAttribute(): string public function getfullNameAttribute(): string
{ {
return "{$this->first_name} {$this->last_name}"; return "{$this->first_name} {$this->last_name}";
} }

View File

@ -16,7 +16,6 @@ class MoveUserDataToProfile extends Command
{ {
$users = User::all(); $users = User::all();
/** @var User $user */
foreach ($users as $user) { foreach ($users as $user) {
$user->profile()->updateOrCreate(["user_id" => $user->id], [ $user->profile()->updateOrCreate(["user_id" => $user->id], [
"first_name" => $user->first_name, "first_name" => $user->first_name,

View File

@ -14,7 +14,7 @@ class SimpleUserResource extends JsonResource
{ {
return [ return [
"id" => $this->id, "id" => $this->id,
"name" => $this->profile->fullName, "name" => $this->profile->full_name,
"email" => $this->email, "email" => $this->email,
"avatar" => $this->profile->getAvatar(), "avatar" => $this->profile->getAvatar(),
]; ];

View File

@ -14,7 +14,7 @@ class UserResource extends JsonResource
{ {
return [ return [
"id" => $this->id, "id" => $this->id,
"name" => $this->profile->fullName, "name" => $this->profile->full_name,
"email" => $this->email, "email" => $this->email,
"role" => $this->role->label(), "role" => $this->role->label(),
"position" => $this->profile->position, "position" => $this->profile->position,

View File

@ -15,7 +15,7 @@ class VacationRequestActivityResource extends JsonResource
return [ return [
"date" => $this->created_at->toDisplayString(), "date" => $this->created_at->toDisplayString(),
"time" => $this->created_at->format("H:i"), "time" => $this->created_at->format("H:i"),
"user" => $this->user ? $this->user->profile->fullName : __("System"), "user" => $this->user ? $this->user->profile->full_name : __("System"),
"state" => $this->to, "state" => $this->to,
]; ];
} }

View File

@ -32,7 +32,7 @@ class SendVacationRequestDaysToGoogleCalendar implements ShouldQueue
$ranges = $this->prepareRanges($days); $ranges = $this->prepareRanges($days);
foreach ($ranges as $range) { foreach ($ranges as $range) {
$text = "{$this->vacationRequest->type->label()} - {$this->vacationRequest->user->profile->fullName} [{$this->vacationRequest->name}]"; $text = "{$this->vacationRequest->type->label()} - {$this->vacationRequest->user->profile->full_name} [{$this->vacationRequest->name}]";
$event = Event::create([ $event = Event::create([
"name" => $text, "name" => $text,

View File

@ -17,7 +17,7 @@
</InertiaLink> </InertiaLink>
<span <span
v-else v-else
class="flex justify-center items-center p-2 text-gray-400 bg-gray-100 rounded-l-md border border-r-0 border-gray-300 cursor-not-allowed md:px-2 md:w-9" class="flex justify-center items-center p-2 text-gray-400 bg-gray-100 rounded-l-md border border-r-0 border-gray-300 md:px-2 md:w-9"
> >
<ChevronLeftIcon class="w-5 h-5" /> <ChevronLeftIcon class="w-5 h-5" />
</span> </span>