ifnex/04_Laravel/app/Enums/ReviewState.php
Kazem Alghasi 61a2643dd0 feat(api): implement shipment review and resubmission workflow
Introduces a complete shipment review system allowing staff to request
changes to customer orders and customers to resubmit corrected orders.

- Add `ReviewState` enum and `ShipmentReview` model to track review history.
- Implement `ShipmentReviewService` to handle approval and change
  request logic.
- Add `resubmit` endpoint for customers to update orders when
  `changes_requested` state is active.
- Add `request-changes` endpoint for staff to flag orders for correction.
- Update `ShipmentResource` in Filament to display review states and
  manage approvals.
- Implement WordPress bridge support for fetching and resubmitting
  orders via AJAX.
- Add database migrations for `shipment_reviews` table and `review_state`
  column on shipments.
- Add `StaffApiMiddleware` to secure staff-specific API routes.
2026-09-27 01:00:26 +03:30

56 lines
1.2 KiB
PHP

<?php
namespace App\Enums;
enum ReviewState: string
{
case Pending = 'pending';
case ChangesRequested = 'changes_requested';
case Approved = 'approved';
case Rejected = 'rejected';
public function label(): string
{
return match ($this) {
self::Pending => 'در انتظار بررسی',
self::ChangesRequested => 'نیازمند اصلاح',
self::Approved => 'تأیید شده',
self::Rejected => 'رد شده',
};
}
public function color(): string
{
return match ($this) {
self::Pending => 'warning',
self::ChangesRequested => 'warning',
self::Approved => 'success',
self::Rejected => 'danger',
};
}
public function isPending(): bool
{
return $this === self::Pending;
}
public function isChangesRequested(): bool
{
return $this === self::ChangesRequested;
}
public function isApproved(): bool
{
return $this === self::Approved;
}
public function isRejected(): bool
{
return $this === self::Rejected;
}
public function canBeResubmitted(): bool
{
return $this === self::ChangesRequested;
}
}