| Total Complexity | 10 |
| Total Lines | 70 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 9 | class Library extends Authenticatable |
||
| 10 | { |
||
| 11 | |||
| 12 | use Notifiable; |
||
|
|
|||
| 13 | |||
| 14 | public function ips() |
||
| 15 | { |
||
| 16 | return $this->hasMany(LibraryIp::class); |
||
| 17 | } |
||
| 18 | |||
| 19 | public function settings() |
||
| 20 | { |
||
| 21 | return $this->hasMany(ThingSettings::class); |
||
| 22 | } |
||
| 23 | |||
| 24 | public function loans() |
||
| 25 | { |
||
| 26 | return $this->hasMany(Loan::class); |
||
| 27 | } |
||
| 28 | |||
| 29 | public function items() |
||
| 30 | { |
||
| 31 | return $this->hasMany(Item::class); |
||
| 32 | } |
||
| 33 | |||
| 34 | public function getOptionsAttribute($value) |
||
| 35 | { |
||
| 36 | if (is_null($value)) { |
||
| 37 | return json_decode('{}', true); |
||
| 38 | } |
||
| 39 | return json_decode($value, true); |
||
| 40 | } |
||
| 41 | |||
| 42 | public function setOptionsAttribute($value) |
||
| 43 | { |
||
| 44 | $this->attributes['options'] = json_encode($value); |
||
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * The database table used by the model. |
||
| 49 | * |
||
| 50 | * @var string |
||
| 51 | */ |
||
| 52 | protected $table = 'libraries'; |
||
| 53 | |||
| 54 | /** |
||
| 55 | * The attributes excluded from the model's JSON form. |
||
| 56 | * |
||
| 57 | * @var array |
||
| 58 | */ |
||
| 59 | protected $hidden = array('password'); |
||
| 60 | |||
| 61 | /** |
||
| 62 | * Get the unique identifier for the user. |
||
| 63 | * |
||
| 64 | * @return mixed |
||
| 65 | */ |
||
| 66 | public function getAuthIdentifierName() |
||
| 67 | { |
||
| 68 | return 'email'; |
||
| 69 | } |
||
| 70 | |||
| 71 | public function getLoansCount() |
||
| 74 | } |
||
| 75 | |||
| 76 | public function getActiveLoansCount() |
||
| 77 | { |
||
| 78 | return $this->loans()->count(); |
||
| 79 | } |
||
| 80 | } |
||
| 81 |