mirror of
https://git.meshkee.com/cssd/cssd-back.git
synced 2026-10-10 20:01:07 +03:30
36 lines
914 B
PHP
36 lines
914 B
PHP
<?php
|
|
|
|
namespace App;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Package extends Model
|
|
{
|
|
public $fillable = [ 'name' , 'unique_id' , 'user_id' , 'note' , 'verified' , 'udi' ];
|
|
|
|
public function user()
|
|
{
|
|
return $this->belongsTo( 'App\User' );
|
|
}
|
|
|
|
public function items()
|
|
{
|
|
return $this->belongsToMany( 'App\Item' , 'item_package' )->withPivot( 'count' );
|
|
}
|
|
|
|
public function labels()
|
|
{
|
|
return $this->hasMany( 'App\Label' );
|
|
}
|
|
|
|
public function transfers()
|
|
{
|
|
return $this->morphMany( 'App\Transfer' , "transferable" )->where( "status" ,"approved" );
|
|
}
|
|
|
|
public function transferActive()
|
|
{
|
|
return $this->morphMany( 'App\Transfer' , "transferable" )->where( "status" ,"approved" )->whereNull( "to_date" );
|
|
}
|
|
}
|