Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| ResendAllInvitationsResource | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
| toArray | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Http\Resources\v2\Company; |
| 4 | |
| 5 | use Illuminate\Http\Request; |
| 6 | use Illuminate\Http\Resources\Json\JsonResource; |
| 7 | |
| 8 | /** |
| 9 | * Resource for the resend-all-invitations response. |
| 10 | * |
| 11 | * The `result` wrapper is applied automatically by ProcessRequestResponseData middleware. |
| 12 | * $wrap is set to null to prevent JsonResource from adding an extra "data" layer, |
| 13 | * since the middleware wraps the full response in "result" rather than replacing "data". |
| 14 | * |
| 15 | * @property int $queued The number of invitation jobs queued for async processing |
| 16 | */ |
| 17 | class ResendAllInvitationsResource extends JsonResource |
| 18 | { |
| 19 | /** |
| 20 | * Disable the default "data" wrapper so the middleware applies "result" cleanly. |
| 21 | * |
| 22 | * @var string|null |
| 23 | */ |
| 24 | public static $wrap = null; |
| 25 | |
| 26 | /** |
| 27 | * Transform the resource into an array. |
| 28 | * |
| 29 | * @return array{queued: int, message: string} |
| 30 | */ |
| 31 | public function toArray(Request $request): array |
| 32 | { |
| 33 | return [ |
| 34 | 'queued' => (int) $this->resource['queued'], |
| 35 | 'message' => sprintf('%d invitation(s) queued for resend.', $this->resource['queued']), |
| 36 | ]; |
| 37 | } |
| 38 | } |