feat: Initialize core application structure including authentication, role-based dashboards, service task management, and integration workflows.
This commit is contained in:
18
app/States/Integration/CancelledState.php
Normal file
18
app/States/Integration/CancelledState.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\States\Integration;
|
||||
|
||||
use App\Enums\IntegrationStatus;
|
||||
|
||||
class CancelledState extends IntegrationState
|
||||
{
|
||||
public function status(): IntegrationStatus
|
||||
{
|
||||
return IntegrationStatus::Cancelled;
|
||||
}
|
||||
|
||||
protected function allowedTransitions(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
18
app/States/Integration/CompletedState.php
Normal file
18
app/States/Integration/CompletedState.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\States\Integration;
|
||||
|
||||
use App\Enums\IntegrationStatus;
|
||||
|
||||
class CompletedState extends IntegrationState
|
||||
{
|
||||
public function status(): IntegrationStatus
|
||||
{
|
||||
return IntegrationStatus::Completed;
|
||||
}
|
||||
|
||||
protected function allowedTransitions(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
21
app/States/Integration/DraftState.php
Normal file
21
app/States/Integration/DraftState.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\States\Integration;
|
||||
|
||||
use App\Enums\IntegrationStatus;
|
||||
|
||||
class DraftState extends IntegrationState
|
||||
{
|
||||
public function status(): IntegrationStatus
|
||||
{
|
||||
return IntegrationStatus::Draft;
|
||||
}
|
||||
|
||||
protected function allowedTransitions(): array
|
||||
{
|
||||
return [
|
||||
IntegrationStatus::PendingRHValidation,
|
||||
IntegrationStatus::Cancelled,
|
||||
];
|
||||
}
|
||||
}
|
||||
22
app/States/Integration/InProgressState.php
Normal file
22
app/States/Integration/InProgressState.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\States\Integration;
|
||||
|
||||
use App\Enums\IntegrationStatus;
|
||||
|
||||
class InProgressState extends IntegrationState
|
||||
{
|
||||
public function status(): IntegrationStatus
|
||||
{
|
||||
return IntegrationStatus::InProgress;
|
||||
}
|
||||
|
||||
protected function allowedTransitions(): array
|
||||
{
|
||||
return [
|
||||
IntegrationStatus::WaitingServices,
|
||||
IntegrationStatus::Completed,
|
||||
IntegrationStatus::Cancelled,
|
||||
];
|
||||
}
|
||||
}
|
||||
33
app/States/Integration/IntegrationState.php
Normal file
33
app/States/Integration/IntegrationState.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\States\Integration;
|
||||
|
||||
use App\Models\IntegrationRequest;
|
||||
use App\Enums\IntegrationStatus;
|
||||
|
||||
abstract class IntegrationState
|
||||
{
|
||||
public function __construct(protected IntegrationRequest $request)
|
||||
{
|
||||
}
|
||||
|
||||
abstract public function status(): IntegrationStatus;
|
||||
|
||||
public function canTransitionTo(IntegrationStatus $status): bool
|
||||
{
|
||||
return in_array($status, $this->allowedTransitions());
|
||||
}
|
||||
|
||||
abstract protected function allowedTransitions(): array;
|
||||
|
||||
public function transitionTo(IntegrationStatus $status): void
|
||||
{
|
||||
if (!$this->canTransitionTo($status)) {
|
||||
throw new \Exception("Transition from {$this->status()->value} to {$status->value} is not allowed.");
|
||||
}
|
||||
|
||||
$this->request->update(['status' => $status]);
|
||||
|
||||
// Trigger events or notifications here
|
||||
}
|
||||
}
|
||||
22
app/States/Integration/PendingRHValidationState.php
Normal file
22
app/States/Integration/PendingRHValidationState.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\States\Integration;
|
||||
|
||||
use App\Enums\IntegrationStatus;
|
||||
|
||||
class PendingRHValidationState extends IntegrationState
|
||||
{
|
||||
public function status(): IntegrationStatus
|
||||
{
|
||||
return IntegrationStatus::PendingRHValidation;
|
||||
}
|
||||
|
||||
protected function allowedTransitions(): array
|
||||
{
|
||||
return [
|
||||
IntegrationStatus::InProgress,
|
||||
IntegrationStatus::Rejected,
|
||||
IntegrationStatus::Cancelled,
|
||||
];
|
||||
}
|
||||
}
|
||||
20
app/States/Integration/RejectedState.php
Normal file
20
app/States/Integration/RejectedState.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\States\Integration;
|
||||
|
||||
use App\Enums\IntegrationStatus;
|
||||
|
||||
class RejectedState extends IntegrationState
|
||||
{
|
||||
public function status(): IntegrationStatus
|
||||
{
|
||||
return IntegrationStatus::Rejected;
|
||||
}
|
||||
|
||||
protected function allowedTransitions(): array
|
||||
{
|
||||
return [
|
||||
IntegrationStatus::Draft,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user