* change layout * change layout * #22 - wip * wip * wip * #22 - wip * #22 - wip * #22 - wip * #22 - wip * #22 - fix * #22 - wip * #22 - added some tests * #22 - wip * #22 - wip * #22 - fix * #22 - wip * #22 - wip * #22 - wip * #22 - fix * #22 - fix * #22 - fix * #22 - fix * #22 - fix * #22 - fix * #22 - cr fixes * #22 - cr fix Co-authored-by: EwelinaLasowy <ewelina.lasowy@blumilk.pl>
This commit is contained in:
80
app/Domain/CalendarGenerator.php
Normal file
80
app/Domain/CalendarGenerator.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Toby\Domain;
|
||||
|
||||
use Carbon\CarbonImmutable;
|
||||
use Carbon\CarbonInterface;
|
||||
use Carbon\CarbonPeriod;
|
||||
use Illuminate\Support\Collection;
|
||||
use Toby\Domain\Enums\VacationRequestState;
|
||||
use Toby\Eloquent\Helpers\YearPeriodRetriever;
|
||||
use Toby\Eloquent\Models\Vacation;
|
||||
use Toby\Eloquent\Models\YearPeriod;
|
||||
|
||||
class CalendarGenerator
|
||||
{
|
||||
public function __construct(
|
||||
protected YearPeriodRetriever $yearPeriodRetriever,
|
||||
) {
|
||||
}
|
||||
|
||||
public function generate(YearPeriod $yearPeriod, string $month): array
|
||||
{
|
||||
$date = CarbonImmutable::create($yearPeriod->year, $this->monthNameToNumber($month));
|
||||
$period = CarbonPeriod::create($date->startOfMonth(), $date->endOfMonth());
|
||||
$holidays = $yearPeriod->holidays()->pluck("date");
|
||||
|
||||
return $this->generateCalendar($period, $holidays);
|
||||
}
|
||||
|
||||
protected function monthNameToNumber($name): int
|
||||
{
|
||||
return match ($name) {
|
||||
default => CarbonInterface::JANUARY,
|
||||
"february" => CarbonInterface::FEBRUARY,
|
||||
"march" => CarbonInterface::MARCH,
|
||||
"april" => CarbonInterface::APRIL,
|
||||
"may" => CarbonInterface::MAY,
|
||||
"june" => CarbonInterface::JUNE,
|
||||
"july" => CarbonInterface::JULY,
|
||||
"august" => CarbonInterface::AUGUST,
|
||||
"september" => CarbonInterface::SEPTEMBER,
|
||||
"october" => CarbonInterface::OCTOBER,
|
||||
"november" => CarbonInterface::NOVEMBER,
|
||||
"december" => CarbonInterface::DECEMBER,
|
||||
};
|
||||
}
|
||||
|
||||
protected function generateCalendar(CarbonPeriod $period, Collection $holidays): array
|
||||
{
|
||||
$calendar = [];
|
||||
$vacations = $this->getVacationsForPeriod($period);
|
||||
|
||||
foreach ($period as $day) {
|
||||
$vacationsForDay = $vacations[$day->toDateString()] ?? new Collection();
|
||||
|
||||
$calendar[] = [
|
||||
"date" => $day->toDateString(),
|
||||
"dayOfMonth" => $day->translatedFormat("j"),
|
||||
"dayOfWeek" => $day->translatedFormat("D"),
|
||||
"isToday" => $day->isToday(),
|
||||
"isWeekend" => $day->isWeekend(),
|
||||
"isHoliday" => $holidays->contains($day),
|
||||
"vacations" => $vacationsForDay->pluck("user_id"),
|
||||
];
|
||||
}
|
||||
|
||||
return $calendar;
|
||||
}
|
||||
|
||||
protected function getVacationsForPeriod(CarbonPeriod $period): Collection
|
||||
{
|
||||
return Vacation::query()
|
||||
->whereBetween("date", [$period->start, $period->end])
|
||||
->whereRelation("vacationRequest", "state", VacationRequestState::Approved->value)
|
||||
->get()
|
||||
->groupBy(fn(Vacation $vacation) => $vacation->date->toDateString());
|
||||
}
|
||||
}
|
@@ -6,10 +6,10 @@ namespace Toby\Domain\Enums;
|
||||
|
||||
enum EmploymentForm: string
|
||||
{
|
||||
case EMPLOYMENT_CONTRACT = "employment_contract";
|
||||
case COMMISSION_CONTRACT = "commission_contract";
|
||||
case B2B_CONTRACT = "b2b_contract";
|
||||
case BOARD_MEMBER_CONTRACT = "board_member_contract";
|
||||
case EmploymentContract = "employment_contract";
|
||||
case ComissionContract = "commission_contract";
|
||||
case B2bContract = "b2b_contract";
|
||||
case BoardMemberContract = "board_member_contract";
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
|
@@ -6,10 +6,10 @@ namespace Toby\Domain\Enums;
|
||||
|
||||
enum Role: string
|
||||
{
|
||||
case EMPLOYEE = "employee";
|
||||
case ADMINISTRATOR = "administrator";
|
||||
case TECHNICAL_APPROVER = "technical_approver";
|
||||
case ADMINISTRATIVE_APPROVER = "administrative_approver";
|
||||
case Employee = "employee";
|
||||
case Administrator = "administrator";
|
||||
case TechnicalApprover = "technical_approver";
|
||||
case AdministrativeApprover = "administrative_approver";
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
|
@@ -6,14 +6,14 @@ namespace Toby\Domain\Enums;
|
||||
|
||||
enum VacationRequestState: string
|
||||
{
|
||||
case CREATED = "created";
|
||||
case CANCELED = "canceled";
|
||||
case REJECTED = "rejected";
|
||||
case APPROVED = "approved";
|
||||
case WAITING_FOR_TECHNICAL = "waiting_for_technical";
|
||||
case WAITING_FOR_ADMINISTRATIVE = "waiting_for_administrative";
|
||||
case ACCEPTED_BY_TECHNICAL = "accepted_by_technical";
|
||||
case ACCEPTED_BY_ADMINSTRATIVE = "accepted_by_administrative";
|
||||
case Created = "created";
|
||||
case Canceled = "canceled";
|
||||
case Rejected = "rejected";
|
||||
case Approved = "approved";
|
||||
case WaitingForTechnical = "waiting_for_technical";
|
||||
case WaitingForAdministrative = "waiting_for_administrative";
|
||||
case AcceptedByTechnical = "accepted_by_technical";
|
||||
case AcceptedByAdministrative = "accepted_by_administrative";
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
@@ -23,24 +23,24 @@ enum VacationRequestState: string
|
||||
public static function pendingStates(): array
|
||||
{
|
||||
return [
|
||||
self::CREATED,
|
||||
self::WAITING_FOR_TECHNICAL,
|
||||
self::WAITING_FOR_ADMINISTRATIVE,
|
||||
self::ACCEPTED_BY_TECHNICAL,
|
||||
self::ACCEPTED_BY_ADMINSTRATIVE,
|
||||
self::Created,
|
||||
self::WaitingForTechnical,
|
||||
self::WaitingForAdministrative,
|
||||
self::AcceptedByTechnical,
|
||||
self::AcceptedByAdministrative,
|
||||
];
|
||||
}
|
||||
|
||||
public static function successStates(): array
|
||||
{
|
||||
return [self::APPROVED];
|
||||
return [self::Approved];
|
||||
}
|
||||
|
||||
public static function failedStates(): array
|
||||
{
|
||||
return [
|
||||
self::REJECTED,
|
||||
self::CANCELED,
|
||||
self::Rejected,
|
||||
self::Canceled,
|
||||
];
|
||||
}
|
||||
|
||||
|
@@ -6,15 +6,15 @@ namespace Toby\Domain\Enums;
|
||||
|
||||
enum VacationType: string
|
||||
{
|
||||
case VACATION = "vacation";
|
||||
case VACATION_ON_REQUEST = "vacation_on_request";
|
||||
case SPECIAL_VACATION = "special_vacation";
|
||||
case CHILDCARE_VACATION = "childcare_vacation";
|
||||
case TRAINING_VACATION = "training_vacation";
|
||||
case UNPAID_VACATION = "unpaid_vacation";
|
||||
case VOLUNTEERING_VACATION = "volunteering_vacation";
|
||||
case TIME_IN_LIEU = "time_in_lieu";
|
||||
case SICK_VACATION = "sick_vacation";
|
||||
case Vacation = "vacation";
|
||||
case OnRequest = "vacation_on_request";
|
||||
case Special = "special_vacation";
|
||||
case Childcare = "childcare_vacation";
|
||||
case Training = "training_vacation";
|
||||
case Unpaid = "unpaid_vacation";
|
||||
case Volunteering = "volunteering_vacation";
|
||||
case TimeInLieu = "time_in_lieu";
|
||||
case Sick = "sick_vacation";
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
|
@@ -16,7 +16,7 @@ class VacationDaysCalculator
|
||||
$period = CarbonPeriod::create($from, $to);
|
||||
$holidays = $yearPeriod->holidays()->pluck("date");
|
||||
|
||||
$validDays = collect();
|
||||
$validDays = new Collection();
|
||||
|
||||
foreach ($period as $day) {
|
||||
if ($this->passes($day, $holidays)) {
|
||||
|
@@ -23,50 +23,50 @@ class VacationRequestStateManager
|
||||
|
||||
public function markAsCreated(VacationRequest $vacationRequest): void
|
||||
{
|
||||
$this->changeState($vacationRequest, VacationRequestState::CREATED);
|
||||
$this->changeState($vacationRequest, VacationRequestState::Created);
|
||||
|
||||
$this->dispatcher->dispatch(new VacationRequestCreated($vacationRequest));
|
||||
}
|
||||
|
||||
public function approve(VacationRequest $vacationRequest): void
|
||||
{
|
||||
$this->changeState($vacationRequest, VacationRequestState::APPROVED);
|
||||
$this->changeState($vacationRequest, VacationRequestState::Approved);
|
||||
|
||||
$this->dispatcher->dispatch(new VacationRequestApproved($vacationRequest));
|
||||
}
|
||||
|
||||
public function reject(VacationRequest $vacationRequest): void
|
||||
{
|
||||
$this->changeState($vacationRequest, VacationRequestState::REJECTED);
|
||||
$this->changeState($vacationRequest, VacationRequestState::Rejected);
|
||||
}
|
||||
|
||||
public function cancel(VacationRequest $vacationRequest): void
|
||||
{
|
||||
$this->changeState($vacationRequest, VacationRequestState::CANCELED);
|
||||
$this->changeState($vacationRequest, VacationRequestState::Canceled);
|
||||
}
|
||||
|
||||
public function acceptAsTechnical(VacationRequest $vacationRequest): void
|
||||
{
|
||||
$this->changeState($vacationRequest, VacationRequestState::ACCEPTED_BY_TECHNICAL);
|
||||
$this->changeState($vacationRequest, VacationRequestState::AcceptedByTechnical);
|
||||
|
||||
$this->dispatcher->dispatch(new VacationRequestAcceptedByTechnical($vacationRequest));
|
||||
}
|
||||
|
||||
public function acceptAsAdministrative(VacationRequest $vacationRequest): void
|
||||
{
|
||||
$this->changeState($vacationRequest, VacationRequestState::ACCEPTED_BY_ADMINSTRATIVE);
|
||||
$this->changeState($vacationRequest, VacationRequestState::AcceptedByAdministrative);
|
||||
|
||||
$this->dispatcher->dispatch(new VacationRequestAcceptedByAdministrative($vacationRequest));
|
||||
}
|
||||
|
||||
public function waitForTechnical(VacationRequest $vacationRequest): void
|
||||
{
|
||||
$this->changeState($vacationRequest, VacationRequestState::WAITING_FOR_TECHNICAL);
|
||||
$this->changeState($vacationRequest, VacationRequestState::WaitingForTechnical);
|
||||
}
|
||||
|
||||
public function waitForAdministrative(VacationRequest $vacationRequest): void
|
||||
{
|
||||
$this->changeState($vacationRequest, VacationRequestState::WAITING_FOR_ADMINISTRATIVE);
|
||||
$this->changeState($vacationRequest, VacationRequestState::WaitingForAdministrative);
|
||||
}
|
||||
|
||||
protected function changeState(VacationRequest $vacationRequest, VacationRequestState $state): void
|
||||
|
@@ -4,23 +4,64 @@ declare(strict_types=1);
|
||||
|
||||
namespace Toby\Domain\Validation\Rules;
|
||||
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Toby\Domain\Enums\VacationRequestState;
|
||||
use Toby\Domain\Enums\VacationType;
|
||||
use Toby\Domain\VacationDaysCalculator;
|
||||
use Toby\Domain\VacationTypeConfigRetriever;
|
||||
use Toby\Eloquent\Models\User;
|
||||
use Toby\Eloquent\Models\VacationRequest;
|
||||
use Toby\Eloquent\Models\YearPeriod;
|
||||
|
||||
class DoesNotExceedLimitRule implements VacationRequestRule
|
||||
{
|
||||
public function __construct(
|
||||
protected VacationTypeConfigRetriever $configRetriever,
|
||||
protected VacationDaysCalculator $vacationDaysCalculator,
|
||||
) {
|
||||
}
|
||||
|
||||
public function check(VacationRequest $vacationRequest): bool
|
||||
{
|
||||
return true;
|
||||
if (!$this->configRetriever->hasLimit($vacationRequest->type)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$limit = $this->getUserVacationLimit($vacationRequest->user, $vacationRequest->yearPeriod);
|
||||
$vacationDays = $this->getVacationDaysWithLimit($vacationRequest->user, $vacationRequest->yearPeriod);
|
||||
$estimatedDays = $this->vacationDaysCalculator->calculateDays($vacationRequest->yearPeriod, $vacationRequest->from, $vacationRequest->to)->count();
|
||||
|
||||
return $limit >= ($vacationDays + $estimatedDays);
|
||||
}
|
||||
|
||||
public function errorMessage(): string
|
||||
{
|
||||
return __("You have exceeded your vacation limit.");
|
||||
return __("Vacation limit has been exceeded.");
|
||||
}
|
||||
|
||||
protected function getUserVacationLimit(User $user, YearPeriod $yearPeriod): int
|
||||
{
|
||||
return $user->vacationLimits()->where("year_period_id", $yearPeriod->id)->first()->days ?? 0;
|
||||
}
|
||||
|
||||
protected function getVacationDaysWithLimit(User $user, YearPeriod $yearPeriod): int
|
||||
{
|
||||
return $user->vacations()
|
||||
->where("year_period_id", $yearPeriod->id)
|
||||
->whereRelation(
|
||||
"vacationRequest",
|
||||
fn(Builder $query) => $query
|
||||
->whereIn("type", $this->getLimitableVacationTypes())
|
||||
->noStates(VacationRequestState::failedStates()),
|
||||
)
|
||||
->count();
|
||||
}
|
||||
|
||||
protected function getLimitableVacationTypes(): Collection
|
||||
{
|
||||
$types = new Collection(VacationType::cases());
|
||||
|
||||
return $types->filter(fn(VacationType $type) => $this->configRetriever->hasLimit($type));
|
||||
}
|
||||
}
|
||||
|
@@ -28,6 +28,7 @@ use Toby\Domain\Enums\Role;
|
||||
* @property Carbon $employment_date
|
||||
* @property Collection $vacationLimits
|
||||
* @property Collection $vacationRequests
|
||||
* @property Collection $vacations
|
||||
*/
|
||||
class User extends Authenticatable
|
||||
{
|
||||
@@ -57,6 +58,11 @@ class User extends Authenticatable
|
||||
return $this->hasMany(VacationRequest::class);
|
||||
}
|
||||
|
||||
public function vacations(): HasMany
|
||||
{
|
||||
return $this->hasMany(Vacation::class);
|
||||
}
|
||||
|
||||
public function scopeSearch(Builder $query, ?string $text): Builder
|
||||
{
|
||||
if ($text === null) {
|
||||
|
43
app/Eloquent/Models/Vacation.php
Normal file
43
app/Eloquent/Models/Vacation.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Toby\Eloquent\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
/**
|
||||
* @property int $id
|
||||
* @property Carbon $date
|
||||
* @property User $user
|
||||
* @property VacationRequest $vacationRequest
|
||||
* @property YearPeriod $yearPeriod
|
||||
*/
|
||||
class Vacation extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
public $timestamps = false;
|
||||
protected $guarded = [];
|
||||
protected $casts = [
|
||||
"date" => "date",
|
||||
];
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
public function vacationRequest(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(VacationRequest::class);
|
||||
}
|
||||
|
||||
public function yearPeriod(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(YearPeriod::class);
|
||||
}
|
||||
}
|
@@ -21,11 +21,11 @@ use Toby\Domain\Enums\VacationType;
|
||||
* @property VacationRequestState $state
|
||||
* @property Carbon $from
|
||||
* @property Carbon $to
|
||||
* @property int $estimated_days
|
||||
* @property string $comment
|
||||
* @property User $user
|
||||
* @property YearPeriod $yearPeriod
|
||||
* @property Collection $activities
|
||||
* @property Collection $vacations
|
||||
* @property Carbon $created_at
|
||||
* @property Carbon $updated_at
|
||||
*/
|
||||
@@ -57,6 +57,11 @@ class VacationRequest extends Model
|
||||
return $this->hasMany(VacationRequestActivity::class);
|
||||
}
|
||||
|
||||
public function vacations(): HasMany
|
||||
{
|
||||
return $this->hasMany(Vacation::class);
|
||||
}
|
||||
|
||||
public function changeStateTo(VacationRequestState $state): void
|
||||
{
|
||||
$this->state = $state;
|
||||
@@ -69,6 +74,11 @@ class VacationRequest extends Model
|
||||
return $query->whereIn("state", $states);
|
||||
}
|
||||
|
||||
public function scopeNoStates(Builder $query, array $states): Builder
|
||||
{
|
||||
return $query->whereNotIn("state", $states);
|
||||
}
|
||||
|
||||
public function scopeOverlapsWith(Builder $query, self $vacationRequest): Builder
|
||||
{
|
||||
return $query->where("from", "<=", $vacationRequest->to)
|
||||
|
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Toby\Infrastructure\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Str;
|
||||
use Inertia\Response;
|
||||
use Toby\Domain\CalendarGenerator;
|
||||
use Toby\Eloquent\Helpers\YearPeriodRetriever;
|
||||
use Toby\Eloquent\Models\User;
|
||||
use Toby\Infrastructure\Http\Resources\UserResource;
|
||||
|
||||
class VacationCalendarController extends Controller
|
||||
{
|
||||
public function index(
|
||||
Request $request,
|
||||
YearPeriodRetriever $yearPeriodRetriever,
|
||||
CalendarGenerator $calendarGenerator,
|
||||
): Response {
|
||||
$month = Str::lower($request->query("month", Carbon::now()->englishMonth));
|
||||
$yearPeriod = $yearPeriodRetriever->selected();
|
||||
$users = User::query()
|
||||
->orderBy("last_name")
|
||||
->orderBy("first_name")
|
||||
->get();
|
||||
|
||||
$calendar = $calendarGenerator->generate($yearPeriod, $month);
|
||||
|
||||
return inertia("Calendar", [
|
||||
"calendar" => $calendar,
|
||||
"currentMonth" => $month,
|
||||
"users" => UserResource::collection($users),
|
||||
]);
|
||||
}
|
||||
}
|
@@ -24,16 +24,21 @@ class VacationRequestController extends Controller
|
||||
{
|
||||
public function index(Request $request, YearPeriodRetriever $yearPeriodRetriever): Response
|
||||
{
|
||||
$status = $request->get("status", "all");
|
||||
|
||||
$vacationRequests = $request->user()
|
||||
->vacationRequests()
|
||||
->with("vacations")
|
||||
->where("year_period_id", $yearPeriodRetriever->selected()->id)
|
||||
->latest()
|
||||
->states(VacationRequestState::filterByStatus($request->query("status", "all")))
|
||||
->states(VacationRequestState::filterByStatus($status))
|
||||
->paginate();
|
||||
|
||||
return inertia("VacationRequest/Index", [
|
||||
"requests" => VacationRequestResource::collection($vacationRequests),
|
||||
"filters" => $request->only("status"),
|
||||
"filters" => [
|
||||
"status" => $status,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -69,15 +74,24 @@ class VacationRequestController extends Controller
|
||||
): RedirectResponse {
|
||||
/** @var VacationRequest $vacationRequest */
|
||||
$vacationRequest = $request->user()->vacationRequests()->make($request->data());
|
||||
$vacationRequest->estimated_days = $vacationDaysCalculator->calculateDays(
|
||||
$vacationRequest->yearPeriod,
|
||||
$vacationRequest->from,
|
||||
$vacationRequest->to,
|
||||
)->count();
|
||||
|
||||
$vacationRequestValidator->validate($vacationRequest);
|
||||
|
||||
$vacationRequest->save();
|
||||
|
||||
$days = $vacationDaysCalculator->calculateDays(
|
||||
$vacationRequest->yearPeriod,
|
||||
$vacationRequest->from,
|
||||
$vacationRequest->to,
|
||||
);
|
||||
|
||||
foreach ($days as $day) {
|
||||
$vacationRequest->vacations()->create([
|
||||
"date" => $day,
|
||||
"user_id" => $vacationRequest->user->id,
|
||||
"year_period_id" => $vacationRequest->yearPeriod->id,
|
||||
]);
|
||||
}
|
||||
|
||||
$stateManager->markAsCreated($vacationRequest);
|
||||
|
||||
return redirect()
|
||||
|
@@ -13,9 +13,11 @@ class VacationRequestActivityResource extends JsonResource
|
||||
public function toArray($request): array
|
||||
{
|
||||
return [
|
||||
"date" => $this->created_at->toDisplayString(),
|
||||
"who" => $this->user ? $this->user->fullName : __("System"),
|
||||
"to" => $this->to->label(),
|
||||
"date" => $this->created_at->format("d.m.Y"),
|
||||
"time" => $this->created_at->format("H:i"),
|
||||
"user" => $this->user ? $this->user->fullName : __("System"),
|
||||
"state" => $this->to,
|
||||
"text" => $this->to->label(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -17,11 +17,11 @@ class VacationRequestResource extends JsonResource
|
||||
"name" => $this->name,
|
||||
"user" => new UserResource($this->user),
|
||||
"type" => $this->type->label(),
|
||||
"state" => $this->state->label(),
|
||||
"state" => $this->state,
|
||||
"from" => $this->from->toDisplayString(),
|
||||
"to" => $this->to->toDisplayString(),
|
||||
"estimatedDays" => $this->estimated_days,
|
||||
"comment" => $this->comment,
|
||||
"days" => VacationResource::collection($this->vacations),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
21
app/Infrastructure/Http/Resources/VacationResource.php
Normal file
21
app/Infrastructure/Http/Resources/VacationResource.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Toby\Infrastructure\Http\Resources;
|
||||
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class VacationResource extends JsonResource
|
||||
{
|
||||
public static $wrap = null;
|
||||
|
||||
public function toArray($request): array
|
||||
{
|
||||
return [
|
||||
"id" => $this->id,
|
||||
"displayDate" => $this->date->toDisplayString(),
|
||||
"date" => $this->date->toDateString(),
|
||||
];
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user