where(function ($q) use ($keyword) { $q->where('name', 'like', "%$keyword%") ->orWhere('unit', 'like', "%$keyword%"); }); } public function unitPrices() { return $this->belongsToMany(UnitPrice::class, 'unit_price_other_costs')->withPivot('qty'); } public function suppliers() { return $this->belongsToMany(Supplier::class, 'supplier_other_cost_prices') ->withPivot('description', 'price'); } public function otherCostCategory() { return $this->belongsTo(OtherCostCategory::class); } }