Initial Commit
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
<?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();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user