create feature sa create list claim and price to work per dealer
This commit is contained in:
@@ -48,4 +48,38 @@ class Dealer extends Model
|
||||
->withPivot('quantity')
|
||||
->withTimestamps();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all work prices for this dealer
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function workPrices()
|
||||
{
|
||||
return $this->hasMany(WorkDealerPrice::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get price for specific work
|
||||
*
|
||||
* @param int $workId
|
||||
* @return WorkDealerPrice|null
|
||||
*/
|
||||
public function getPriceForWork($workId)
|
||||
{
|
||||
return $this->workPrices()
|
||||
->where('work_id', $workId)
|
||||
->active()
|
||||
->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all active work prices for this dealer
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
||||
*/
|
||||
public function activeWorkPrices()
|
||||
{
|
||||
return $this->hasMany(WorkDealerPrice::class)->active();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user