30 lines
841 B
PHP
30 lines
841 B
PHP
|
<?php
|
||
|
|
||
|
namespace App\Models;
|
||
|
|
||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||
|
use Illuminate\Database\Eloquent\Model;
|
||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||
|
|
||
|
class Cabel extends Model
|
||
|
{
|
||
|
use HasFactory, SoftDeletes;
|
||
|
|
||
|
public function category(): BelongsTo
|
||
|
{
|
||
|
return $this->belongsTo(CabelCategory::class,'cabel_category_id')->withTrashed();
|
||
|
}
|
||
|
|
||
|
public function loans()
|
||
|
{
|
||
|
return $this->morphtoMany(User::class, 'loanable','loans')->where('loan_type_id','=',LoanType::where('name','=','Loan')->first()->id)->withTrashed();
|
||
|
}
|
||
|
|
||
|
public function reservations()
|
||
|
{
|
||
|
return $this->morphtoMany(User::class, 'loanable','loans')->where('loan_type_id','!=',LoanType::where('name','=','Loan')->first()->id)->withTrashed();
|
||
|
}
|
||
|
|
||
|
}
|