| Conditions | 1 |
| Paths | 1 |
| Total Lines | 15 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 15 | public function toArray($request) |
||
| 16 | { |
||
| 17 | return [ |
||
| 18 | 'type' => 'item', |
||
| 19 | 'id' => $this->id, |
||
|
|
|||
| 20 | 'barcode' => $this->barcode, |
||
| 21 | 'note' => $this->note, |
||
| 22 | 'created_at' => $this->created_at->toDateTimeString(), |
||
| 23 | 'updated_at' => $this->updated_at->toDateTimeString(), |
||
| 24 | |||
| 25 | 'thing' => ThingResource::make($this->whenLoaded('thing')), |
||
| 26 | 'library' => LibraryResource::make($this->whenLoaded('library')), |
||
| 27 | |||
| 28 | // If 'loans' is eager-loaded, this will only require one query. |
||
| 29 | 'available' => count($this->loans) === 0, |
||
| 30 | ]; |
||
| 33 |