cacheKey, $this->cacheTtl, function () { return $this->model->with('country:id,name')->get(); }); } public function find(int $id): ?State { return $this->model->with('country:id,name')->find($id); } public function create(StateDTO $dto): State { Cache::forget($this->cacheKey); return $this->model->create($dto->toArray()); } public function update(int $id, StateDTO $dto, array $fieldsToUpdate): State { $record = $this->find($id); $updateFields = array_intersect_key( $dto->toArray(), array_flip($fieldsToUpdate) ); $record->update($updateFields); Cache::forget($this->cacheKey); return $record->fresh(); } public function delete(int $id): bool { Cache::forget($this->cacheKey); return $this->model->destroy($id) > 0; } }