create feature sa create list claim and price to work per dealer

This commit is contained in:
2025-07-07 19:11:04 +07:00
parent fa554446ca
commit 956df5cfe6
16 changed files with 3062 additions and 404 deletions

View File

@@ -54,4 +54,52 @@ class Work extends Model
{
return $this->belongsTo(Category::class);
}
/**
* Get all dealer prices for this work
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function dealerPrices()
{
return $this->hasMany(WorkDealerPrice::class);
}
/**
* Get price for specific dealer
*
* @param int $dealerId
* @return WorkDealerPrice|null
*/
public function getPriceForDealer($dealerId)
{
return $this->dealerPrices()
->where('dealer_id', $dealerId)
->active()
->first();
}
/**
* Get price for specific dealer (including soft deleted)
*
* @param int $dealerId
* @return WorkDealerPrice|null
*/
public function getPriceForDealerWithTrashed($dealerId)
{
return $this->dealerPrices()
->withTrashed()
->where('dealer_id', $dealerId)
->first();
}
/**
* Get all active prices for this work
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function activeDealerPrices()
{
return $this->hasMany(WorkDealerPrice::class)->active();
}
}