Initial Commit
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Loan extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
protected $fillable = [
|
||||
'user_id',
|
||||
'room_id',
|
||||
'loan_type_id',
|
||||
'loanable_id',
|
||||
'loanable_type',
|
||||
'date_start',
|
||||
'date_end',
|
||||
'date_deadline',
|
||||
];
|
||||
|
||||
|
||||
public function user()
|
||||
{
|
||||
return $this->belongsTo(User::class, 'user_id')->withTrashed();
|
||||
}
|
||||
|
||||
public function room()
|
||||
{
|
||||
return $this->belongsTo(Room::class, 'room_id')->withTrashed();
|
||||
}
|
||||
|
||||
public function type()
|
||||
{
|
||||
return $this->belongsTo(LoanType::class, 'loan_type_id');
|
||||
}
|
||||
|
||||
public function loanable()
|
||||
{
|
||||
return $this->morphTo()->withTrashed();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user