base commit

This commit is contained in:
Mekan1206
2026-07-30 17:24:40 +05:00
commit a794dacd39
345 changed files with 29597 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
namespace App\Observers;
use App\Models\DisciplinaryReport;
use App\Models\User;
use App\Notifications\DisciplinaryReportCreatedNotification;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Notification;
class DisciplinaryReportObserver
{
public function creating(DisciplinaryReport $report): void
{
if ($report->created_by === null) {
$report->created_by = Auth::id();
}
}
public function created(DisciplinaryReport $report): void
{
Notification::send(
User::role('hr_manager')->get(),
new DisciplinaryReportCreatedNotification($report),
);
}
}

View File

@@ -0,0 +1,17 @@
<?php
declare(strict_types=1);
namespace App\Observers;
use App\Models\EmployeeDocument;
class EmployeeDocumentObserver
{
public function creating(EmployeeDocument $document): void
{
if ($document->uploaded_at === null) {
$document->uploaded_at = now();
}
}
}

View File

@@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
namespace App\Observers;
use App\Models\SickLeave;
use App\Services\Leave\LeaveDaysCalculator;
class SickLeaveObserver
{
public function __construct(
private readonly LeaveDaysCalculator $leaveDaysCalculator,
) {}
public function saving(SickLeave $sickLeave): void
{
if ($sickLeave->start_date === null || $sickLeave->end_date === null) {
return;
}
$sickLeave->days = $this->leaveDaysCalculator->between(
$sickLeave->start_date,
$sickLeave->end_date,
);
}
}

View File

@@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
namespace App\Observers;
use App\Enums\ApprovalStatus;
use App\Models\UnpaidLeave;
use App\Services\Leave\LeaveDaysCalculator;
class UnpaidLeaveObserver
{
public function __construct(
private readonly LeaveDaysCalculator $leaveDaysCalculator,
) {}
public function creating(UnpaidLeave $unpaidLeave): void
{
if ($unpaidLeave->status === null) {
$unpaidLeave->status = ApprovalStatus::Pending;
}
}
public function saving(UnpaidLeave $unpaidLeave): void
{
if ($unpaidLeave->start_date === null || $unpaidLeave->end_date === null) {
return;
}
$unpaidLeave->days = $this->leaveDaysCalculator->between(
$unpaidLeave->start_date,
$unpaidLeave->end_date,
);
}
}

View File

@@ -0,0 +1,35 @@
<?php
declare(strict_types=1);
namespace App\Observers;
use App\Enums\ApprovalStatus;
use App\Models\Vacation;
use App\Services\Leave\LeaveDaysCalculator;
class VacationObserver
{
public function __construct(
private readonly LeaveDaysCalculator $leaveDaysCalculator,
) {}
public function creating(Vacation $vacation): void
{
if ($vacation->status === null) {
$vacation->status = ApprovalStatus::Pending;
}
}
public function saving(Vacation $vacation): void
{
if ($vacation->start_date === null || $vacation->end_date === null) {
return;
}
$vacation->days = $this->leaveDaysCalculator->between(
$vacation->start_date,
$vacation->end_date,
);
}
}