select(['id', 'name', 'phone_number', 'address']) ->when($search, fn ($q) => $q->where('name', 'like', "%{$search}%")) ->orderBy($sort, $direction) ->paginate($perPage); } public function getAll(): Collection { return Customer::select(['id', 'name'])->orderBy('name')->get(); } public function store(array $data): Customer { $customer = Customer::create($data); $this->logCreated($customer, 'Customer', [ 'Nama' => $customer->name, 'No. Telepon' => $customer->phone_number, 'Alamat' => $customer->address, ]); return $customer; } public function update(Customer $customer, array $data): Customer { $oldValues = [ 'Nama' => $customer->name, 'No. Telepon' => $customer->phone_number, 'Alamat' => $customer->address, ]; $customer->update($data); $this->logUpdated($customer, 'Customer', $oldValues, [ 'Nama' => $customer->name, 'No. Telepon' => $customer->phone_number, 'Alamat' => $customer->address, ]); return $customer; } public function destroy(Customer $customer): bool { $this->logDeleted($customer, 'Customer', [ 'Nama' => $customer->name, 'No. Telepon' => $customer->phone_number, 'Alamat' => $customer->address, ]); return $customer->delete(); } }