mirror of
https://git.meshkee.com/cssd/cssd-back.git
synced 2026-10-11 00:01:07 +03:30
36 lines
959 B
PHP
36 lines
959 B
PHP
<?php
|
|
|
|
namespace App;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class Item extends Model
|
|
{
|
|
public $fillable = [ 'name' , 'size' , 'unique_id' , 'specific' , 'note' , 'user_id' , 'udi' , 'status' , 'repair' ];
|
|
|
|
public function packages()
|
|
{
|
|
return $this->belongsToMany( 'App\Package' , 'item_package' )->withPivot( 'count' );
|
|
}
|
|
|
|
public function user()
|
|
{
|
|
return $this->belongsTo( 'App\User' );
|
|
}
|
|
|
|
public function files()
|
|
{
|
|
return $this->morphMany( 'App\Media' , 'model' );
|
|
}
|
|
|
|
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" );
|
|
}
|
|
}
|