belongsTo(InvoiceService::class); } public function childs() { return $this->hasMany(UnitPrice::class, 'parent_id'); } public function parent() { return $this->belongsTo(UnitPrice::class, 'parent_id'); } public function scopeWhereHasBudgetPlan($q, $id) { return $q->whereHas('budgetPlans', function ($q) use ($id) { $q->where('budget_plans.id', $id); }); } public function budgetPlans() { return $this->belongsToMany(BudgetPlan::class, 'budget_plan_prices') ->using(BudgetPlanPrice::class) ->withPivot('id', 'price', 'qty', 'subtotal', 'images'); } public function qualityControls() { return $this->hasMany(QualityControl::class); } public function fees() { return $this->belongsToMany(Fee::class, 'unit_price_fees') ->withPivot('qty'); } public function materials() { return $this->belongsToMany(Material::class, 'unit_price_materials') ->withPivot('qty'); } public function vendorProducts() { return $this->belongsToMany(VendorProduct::class, 'unit_price_products') ->withPivot('qty'); } public function budgetPlanPrice() { return $this->hasOne(BudgetPlanPrice::class); } public function purchaseRequestMaterialDetails() { return $this->hasMany(PurchaseRequestMaterialDetail::class); } }