| Conditions | 4 |
| Paths | 4 |
| Total Lines | 22 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 36 | public function passes($attribute, $value) |
||
| 37 | { |
||
| 38 | if (is_null($this->item)) { |
||
| 39 | return true; |
||
| 40 | } |
||
| 41 | |||
| 42 | if (is_a($this->item, AlmaItem::class)) { |
||
| 43 | $almaLoan = $this->item->loan; |
||
| 44 | $this->msg = 'Dokumentet er allerede utlånt i Alma.'; |
||
| 45 | |||
| 46 | return is_null($almaLoan); |
||
| 47 | } |
||
| 48 | |||
| 49 | // Always true if the item is a generic representation without barcode |
||
| 50 | if (is_null($this->item->barcode)) { |
||
| 51 | return true; |
||
| 52 | } |
||
| 53 | |||
| 54 | // Check if already on loan |
||
| 55 | $loan = $this->item->loans()->first(); |
||
| 56 | |||
| 57 | return is_null($loan); |
||
| 58 | } |
||
| 70 |