Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/deploy-to-beta-manually.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ jobs:
rm: true

- name: run deployment script over ssh
uses: appleboy/ssh-action@823bd89e131d8d508129f9443cad5855e9ba96f0 # v1.2.4
uses: appleboy/ssh-action@0ff4204d59e8e51228ff73bce53f80d53301dee2 # v1.2.5
with:
timeout: 10s
command_timeout: 10m
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-to-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jobs:
target: ${{ secrets.TOBY_VPS_LIVE_APP_PATH }}
rm: true

- uses: appleboy/ssh-action@823bd89e131d8d508129f9443cad5855e9ba96f0 # v1.2.4
- uses: appleboy/ssh-action@0ff4204d59e8e51228ff73bce53f80d53301dee2 # v1.2.5
with:
timeout: 10s
command_timeout: 10m
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-command-on-beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-24.04
steps:
- name: run php artisan command
uses: appleboy/ssh-action@823bd89e131d8d508129f9443cad5855e9ba96f0 # v1.2.4
uses: appleboy/ssh-action@0ff4204d59e8e51228ff73bce53f80d53301dee2 # v1.2.5
with:
timeout: 10s
command_timeout: 10m
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-and-lint-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- name: Set up node
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: 22.17.1
node-version: 22.22.2

- name: Instal npm dependencies
run: npm clean-install
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test-and-lint-php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ jobs:
runs-on: ubuntu-24.04
env:
# renovate: datasource=docker depName=php
PHP_VERSION: 8.4.16
PHP_VERSION: 8.4.20
services:
postgres:
image: postgres:15@sha256:a7711af921c380de0fda7c48a61fab5ac4def145fd9fc00ccea7355fd6270bb4
image: postgres:15@sha256:32016c79bea24c14917660106bc23a03341d94b9983aeb41f4130b4f3fbd6dd0
env:
POSTGRES_DB: toby-test
POSTGRES_USER: toby
Expand All @@ -53,7 +53,7 @@ jobs:
restore-keys: ${{ runner.os }}-composer-dependencies

- name: Setup PHP
uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # 2.36.0
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f # 2.37.0
with:
php-version: ${{ env.PHP_VERSION }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_pgsql, intl, gd
Expand Down
9 changes: 7 additions & 2 deletions app/Domain/DashboardAggregator.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Support\Carbon;
use Laragear\CacheQuery\Cache;
use Toby\Http\Resources\BirthdayResource;
use Toby\Http\Resources\DashboardVacationRequestResource;
use Toby\Http\Resources\HolidayResource;
Expand Down Expand Up @@ -53,7 +54,9 @@ public function aggregateCalendarData(User $user, ?int $year = null): array
->vacations()
->with(["vacationRequest.vacations", "vacationRequest.user.profile"])
->whereYear("date", $year ?? Carbon::now()->year)
->cache("vacations:{$user->id}")
->cache(function (Cache $cache) use ($user): void {
$cache->ttl(60)->as("vacations:{$user->id}");
})
->approved()
->get()
->mapWithKeys(
Expand All @@ -66,7 +69,9 @@ public function aggregateCalendarData(User $user, ?int $year = null): array
->vacations()
->with(["vacationRequest.vacations", "vacationRequest.user.profile"])
->whereYear("date", $year ?? Carbon::now()->year)
->cache("vacations:{$user->id}")
->cache(function (Cache $cache) use ($user): void {
$cache->ttl(60)->as("vacations:{$user->id}");
})
->pending()
->get()
->mapWithKeys(
Expand Down
9 changes: 7 additions & 2 deletions app/Domain/UserVacationStatsRetriever.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Carbon;
use Illuminate\Support\Collection;
use Laragear\CacheQuery\Cache;
use Toby\Enums\VacationType;
use Toby\Models\User;
use Toby\Models\Vacation;
Expand Down Expand Up @@ -103,15 +104,19 @@ public function getVacationDaysLimit(User $user, ?int $year = null): int
{
return $user->vacationLimits()
->where("year", $year ?? Carbon::today()->year)
->cache("vacations:{$user->id}")
->cache(function (Cache $cache) use ($user): void {
$cache->ttl(60)->as("vacations:{$user->id}");
})
->first()?->limit ?? 0;
}

public function hasVacationDaysLimit(User $user, ?int $year = null): bool
{
return $user->vacationLimits()
->where("year", $year ?? Carbon::today()->year)
->cache("vacations:{$user->id}")
->cache(function (Cache $cache) use ($user): void {
$cache->ttl(60)->as("vacations:{$user->id}");
})
->first()?->hasVacation() ?? false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __invoke(
UnavailableDaysRetriever $unavailableDaysRetriever,
): JsonResponse {
/** @var User $user */
$user = User::query()->find($request->get("user"));
$user = User::query()->find($request->input("user"));
$year = $request->getYear();

$unavailableDays = $unavailableDaysRetriever->getUnavailableDays($user, $year, $request->vacationType())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function __invoke(
UserVacationStatsRetriever $vacationStatsRetriever,
): JsonResponse {
/** @var User $user */
$user = User::query()->find($request->get("user"));
$user = User::query()->find($request->input("user"));
$year = $request->getYear();

$limit = $vacationStatsRetriever->getVacationDaysLimit($user, $year);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function __invoke(
VacationTypeConfigRetriever $configRetriever,
): JsonResponse {
/** @var User $user */
$user = User::query()->find($request->get("user"));
$user = User::query()->find($request->input("user"));
$currentUser = $request->user();

$types = VacationType::all()
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/AssignedBenefitController.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function update(AssignedBenefitsRequest $request): RedirectResponse
->first();

$data = Arr::where(
$request->get("data"),
$request->input("data"),
fn(array $item): bool => $users->contains(fn(User $user): bool => $user->id === $item["user"]),
);

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/BenefitsReportController.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function store(BenefitsReportRequest $request): RedirectResponse
{
$this->authorize("manageBenefits");

$nameReport = $request->get("name");
$nameReport = $request->input("name");

$users = User::query()
->withTrashed($request->user()->canSeeInactiveUsers())
Expand Down
27 changes: 18 additions & 9 deletions app/Http/Controllers/OvertimeRequestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Illuminate\Http\Request;
use Illuminate\Support\Carbon;
use Inertia\Response;
use Laragear\CacheQuery\Cache;
use Toby\Actions\OvertimeRequest\AcceptAsTechnicalAction;
use Toby\Actions\OvertimeRequest\CancelAction;
use Toby\Actions\OvertimeRequest\CreateAction;
Expand All @@ -35,7 +36,7 @@ public function index(Request $request): RedirectResponse|Response
$user = $request->user();
$this->authorize("canUseOvertimeRequestFunctionality", $user);

$status = $request->get("status", "all");
$status = $request->input("status", "all");
$year = $request->integer("year", Carbon::now()->year);

$overtimeRequests = $user
Expand All @@ -50,28 +51,36 @@ public function index(Request $request): RedirectResponse|Response
->overtimeRequests()
->whereYear("from", $year)
->states(OvertimeRequestStatesRetriever::pendingStates())
->cache(key: "overtime:{$user->id}")
->cache(function (Cache $cache) use ($user): void {
$cache->ttl(60)->as("overtime:{$user->id}");
})
->count();

$success = $user
->overtimeRequests()
->whereYear("from", $year)
->states(OvertimeRequestStatesRetriever::successStates())
->cache(key: "overtime:{$user->id}")
->cache(function (Cache $cache) use ($user): void {
$cache->ttl(60)->as("overtime:{$user->id}");
})
->count();

$failed = $user
->overtimeRequests()
->whereYear("from", $year)
->states(OvertimeRequestStatesRetriever::failedStates())
->cache(key: "overtime:{$user->id}")
->cache(function (Cache $cache) use ($user): void {
$cache->ttl(60)->as("overtime:{$user->id}");
})
->count();

$settled = $user
->overtimeRequests()
->whereYear("from", $year)
->states(OvertimeRequestStatesRetriever::settledStates())
->cache(key: "overtime:{$user->id}")
->cache(function (Cache $cache) use ($user): void {
$cache->ttl(60)->as("overtime:{$user->id}");
})
->count();

return inertia("OvertimeRequest/Index", [
Expand All @@ -97,9 +106,9 @@ public function indexForApprovers(
abort(403);
}

$status = $request->get("status", "all");
$user = $request->get("user");
$year = $request->get("year");
$status = $request->input("status", "all");
$user = $request->input("user");
$year = $request->input("year");

$authUser = $request->user();
$withTrashedUsers = $authUser->canSeeInactiveUsers();
Expand Down Expand Up @@ -151,7 +160,7 @@ public function create(Request $request): Response

return inertia("OvertimeRequest/Create", [
"settlementTypes" => SettlementType::casesToSelect(),
"overtimeFromDate" => $request->get("from_date"),
"overtimeFromDate" => $request->input("from_date"),
]);
}

Expand Down
29 changes: 18 additions & 11 deletions app/Http/Controllers/VacationRequestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Illuminate\Support\Carbon;
use Illuminate\Validation\ValidationException;
use Inertia\Response;
use Laragear\CacheQuery\Cache;
use Symfony\Component\HttpFoundation\Response as SymfonyResponse;
use Toby\Actions\VacationRequest\AcceptAsAdministrativeAction;
use Toby\Actions\VacationRequest\AcceptAsTechnicalAction;
Expand Down Expand Up @@ -46,7 +47,7 @@ public function index(Request $request): Response|RedirectResponse
}

$year = $request->integer("year", Carbon::now()->year);
$status = $request->get("status", "all");
$status = $request->input("status", "all");
$withoutRemote = $request->boolean("withoutRemote");

$vacationRequests = $user
Expand All @@ -63,23 +64,29 @@ public function index(Request $request): Response|RedirectResponse
->whereYear("from", $year)
->states(VacationRequestStatesRetriever::pendingStates())
->when($withoutRemote, fn(Builder $query): Builder => $query->excludeType(VacationType::RemoteWork))
->cache(key: "vacations:{$user->id}")
->cache(function (Cache $cache) use ($user): void {
$cache->ttl(60)->as("vacations:{$user->id}");
})
->count();

$success = $user
->vacationRequests()
->whereYear("from", $year)
->states(VacationRequestStatesRetriever::successStates())
->when($withoutRemote, fn(Builder $query): Builder => $query->excludeType(VacationType::RemoteWork))
->cache(key: "vacations:{$user->id}")
->cache(function (Cache $cache) use ($user): void {
$cache->ttl(60)->as("vacations:{$user->id}");
})
->count();

$failed = $user
->vacationRequests()
->whereYear("from", $year)
->states(VacationRequestStatesRetriever::failedStates())
->when($withoutRemote, fn(Builder $query): Builder => $query->excludeType(VacationType::RemoteWork))
->cache(key: "vacations:{$user->id}")
->cache(function (Cache $cache) use ($user): void {
$cache->ttl(60)->as("vacations:{$user->id}");
})
->count();

return inertia("VacationRequest/Index", [
Expand All @@ -104,15 +111,15 @@ public function indexForApprovers(
return redirect()->route("vacation.requests.index");
}

$year = $request->get("year");
$status = $request->get("status", "all");
$type = $request->get("type");
$year = $request->input("year");
$status = $request->input("status", "all");
$type = $request->input("type");
$authUser = $request->user();
$withTrashedUsers = $authUser->canSeeInactiveUsers();

$user = User::query()
->withTrashed($withTrashedUsers)
->where("id", $request->get("user"))
->where("id", $request->input("user"))
->first();

$vacationRequests = VacationRequest::query()
Expand Down Expand Up @@ -243,8 +250,8 @@ public function create(Request $request): Response
return inertia("VacationRequest/Create", [
"vacationTypes" => VacationType::casesToSelect(),
"users" => SimpleUserResource::collection($users),
"vacationUserId" => (int)$request->get("user"),
"vacationFromDate" => $request->get("from_date"),
"vacationUserId" => (int)$request->input("user"),
"vacationFromDate" => $request->input("from_date"),
]);
}

Expand All @@ -268,7 +275,7 @@ public function bulkCreate(Request $request, VacationTypeConfigRetriever $config
"types" => VacationType::casesToSelect(),
"users" => SimpleUserResource::collection($users),
"typesByUser" => $typesByUser ?? [],
"vacationFromDate" => $request->get("from_date"),
"vacationFromDate" => $request->input("from_date"),
]);
}

Expand Down
13 changes: 10 additions & 3 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Illuminate\Support\Carbon;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB;
use Laragear\CacheQuery\Cache;
use Laravel\Sanctum\HasApiTokens;
use Spatie\Permission\Traits\HasRoles;
use Toby\Enums\EmploymentForm;
Expand Down Expand Up @@ -100,7 +101,9 @@ public function lastMedicalExam(): ?UserHistory
return $this->histories()
->where("type", UserHistoryType::MedicalExam)
->orderBy("to", "desc")
->cache("user:history{$this->id}")
->cache(function (Cache $cache): void {
$cache->ttl(60)->as("user:history:{$this->id}");
})
->first();
}

Expand All @@ -109,7 +112,9 @@ public function lastOhsTraining(): ?UserHistory
return $this->histories()
->where("type", UserHistoryType::OhsTraining)
->orderBy("to", "desc")
->cache("user:history{$this->id}")
->cache(function (Cache $cache): void {
$cache->ttl(60)->as("user:history:{$this->id}");
})
->first();
}

Expand All @@ -119,7 +124,9 @@ public function startOfEmploymentInCurrentCompany(): ?UserHistory
->where("type", UserHistoryType::Employment)
->where("is_employed_at_current_company", true)
->orderBy("from")
->cache("user:history{$this->id}")
->cache(function (Cache $cache): void {
$cache->ttl(60)->as("user:history:{$this->id}");
})
->first();
}

Expand Down
Loading
Loading