Changeset View
Changeset View
Standalone View
Standalone View
src/app/Library.php
- This file was added.
<?php | |||||
namespace App; | |||||
use App\Traits\UuidStrKeyTrait; | |||||
use Illuminate\Database\Eloquent\Model; | |||||
/** | |||||
* The eloquent definition of a library. | |||||
* | |||||
* A library is owned by an {@link \App\User}. | |||||
* | |||||
* @property string $id Unique identifier | |||||
* @property string $name Name | |||||
* @property int $user_id Owner's identifier | |||||
*/ | |||||
class Library extends Model | |||||
{ | |||||
use UuidStrKeyTrait; | |||||
/** @var array<int, string> The attributes that are mass assignable */ | |||||
protected $fillable = [ | |||||
'name', | |||||
'user_id', | |||||
]; | |||||
/** @var array<int, string> The attributes that can be not set */ | |||||
protected $nullable = [ | |||||
'name', | |||||
]; | |||||
/** | |||||
* Files in this library. | |||||
* | |||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany | |||||
*/ | |||||
public function files() | |||||
{ | |||||
return $this->hasMany(File::class); | |||||
} | |||||
/** | |||||
* The user the library belongs to. | |||||
* | |||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo | |||||
*/ | |||||
public function user() | |||||
{ | |||||
return $this->belongsTo(User::class, 'user_id', 'id'); | |||||
} | |||||
} |