Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 16 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| StockInputConcludedResource | |
0.00% |
0 / 16 |
|
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
| toArray | |
0.00% |
0 / 16 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Domain\StockIO\Resources; |
| 4 | |
| 5 | use App\Models\Transferable\Transferable; |
| 6 | use Domain\Integration\Resources\IntegrationResource; |
| 7 | use Domain\StockIO\Enums\StockStatusEnum; |
| 8 | use Domain\StockIO\Enums\StockTypeEnum; |
| 9 | use Domain\Team\Resources\TeamResource; |
| 10 | use Domain\User\Resources\UserResource; |
| 11 | use Illuminate\Database\Eloquent\Collection; |
| 12 | use Illuminate\Http\Request; |
| 13 | use Illuminate\Http\Resources\Json\JsonResource; |
| 14 | |
| 15 | /** |
| 16 | * @property StockStatusEnum $status |
| 17 | * @property ?string $observation |
| 18 | * @property Collection $items |
| 19 | * @property StockTypeEnum $type |
| 20 | * @property array $data |
| 21 | * @property int $id |
| 22 | * @property Transferable|null $transferable |
| 23 | * @property string $created_at |
| 24 | * @property bool $urgent |
| 25 | * @property int $reason |
| 26 | */ |
| 27 | class StockInputConcludedResource extends JsonResource |
| 28 | { |
| 29 | public function toArray(Request $request): array |
| 30 | { |
| 31 | return [ |
| 32 | 'id' => $this->id, |
| 33 | 'transferable_id' => $this->whenLoaded('transferable', $this->transferable?->getKey()), |
| 34 | 'products' => $this->whenLoaded('transferable', function () { |
| 35 | return $this->transferable->transactionsFrom->pluck('item')->pluck('product'); |
| 36 | }), |
| 37 | 'urgent' => $this->urgent, |
| 38 | 'observation' => $this->observation, |
| 39 | 'status' => $this->status->value, |
| 40 | 'type' => $this->type->value, |
| 41 | 'reason' => $this->reason, |
| 42 | 'team'=> TeamResource::make($this->whenLoaded('team')), |
| 43 | 'created_at' => (string)$this->created_at, |
| 44 | 'responsible' => UserResource::make($this->whenLoaded('responsible')), |
| 45 | 'integration' => IntegrationResource::make($this->whenLoaded('integration')), |
| 46 | ]; |
| 47 | } |
| 48 | |
| 49 | } |