mirror of
https://git.meshkee.com/cssd/cssd-back.git
synced 2026-10-10 20:51:07 +03:30
52 lines
1.2 KiB
PHP
52 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App;
|
|
|
|
use App\Constants\StatusTypeEnum;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Package extends Model
|
|
{
|
|
public $fillable = ['name', 'user_id', 'note', 'status', 'creator_id'];
|
|
|
|
public function user()
|
|
{
|
|
return $this->belongsTo('App\User');
|
|
}
|
|
|
|
public function creator()
|
|
{
|
|
return $this->belongsTo('App\User', "creator_id");
|
|
}
|
|
|
|
public function items()
|
|
{
|
|
return $this->hasMany('App\Item');
|
|
}
|
|
|
|
public function labels()
|
|
{
|
|
return $this->hasMany('App\Label');
|
|
}
|
|
|
|
public function transfersAll()
|
|
{
|
|
return $this->morphMany('App\Transfer', "transferable")->orderBy("id", "desc");
|
|
}
|
|
|
|
public function transfers()
|
|
{
|
|
return $this->morphMany('App\Transfer', "transferable")->where("status", StatusTypeEnum::APPROVED)->orderBy("id", "desc");
|
|
}
|
|
|
|
public function latestTransfer()
|
|
{
|
|
return $this->morphOne('App\Transfer', "transferable")->where("status", StatusTypeEnum::APPROVED)->orderBy("id", "desc")->latest();
|
|
}
|
|
|
|
public function transferActive()
|
|
{
|
|
return $this->morphMany('App\Transfer', "transferable")->where("status", StatusTypeEnum::APPROVED)->whereNull("to_date")->orderBy("id", "desc");
|
|
}
|
|
}
|