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->hasMany( 'App\Transfer' )->where( "status" ,"approved" ); } public function transferActive() { return $this->hasOne( 'App\Transfer' )->where( "status" ,"approved" )->whereNull( "to_date" ); } }