ucwords($value) ); } protected function unit(): Attribute { return Attribute::make( set:fn($value) => strtoupper($value) ); } protected function price(): Attribute { return Attribute::make( get:fn($value) => (new CurrencyFormatService)->setRupiahFormat($value, true) ); } public function scopeFilter($query, $search) { $query->when($search ?? null, function ($query, $search) { $query->where(function ($query) use ($search) { $query->where('name', 'like', '%' . $search . '%') ->orWhere('price', 'like', '%' . $search . '%') ->orWhere('unit', 'like', '%' . $search . '%'); }); }); } }