repository = new ContentWatermarksRepository(); } public function index(Request $request) { return $this->repository->getCollection(); } public function store(StoreContentWatermarkRequest $request) { $watermark = $this->repository->store($request); if ($watermark) { $watermark->load(['contentType', 'contentVariant']); return response()->json([ 'message' => 'Watermark has been saved.', 'watermark' => $this->repository->toResource($watermark), 'watermarks' => $this->repository->getCollection() ]); } return response()->json([ 'message' => 'Failed to save watermark.' ], 400); } public function update(StoreContentWatermarkRequest $request) { $watermark = $this->repository->find($request->id); if ($watermark) { $this->repository->update($watermark, $request); return response()->json([ 'message' => 'Watermark has been updated.', 'watermark' => $this->repository->toResource($watermark), 'watermarks' => $this->repository->getCollection() ]); } return response()->json([ 'message' => 'Watermark not found.' ], 404); } public function setStatus(Request $request) { if ($request->has('id')) { $watermark = $this->repository->find($request->id); if ($watermark) { $this->repository->update($watermark, ['active' => $request->active]); return response()->json([ 'message' => 'Watermark status has been updated.', 'watermarks' => $this->repository->getCollection() ]); } return response()->json([ 'message' => 'Watermark not found.' ], 404); } return response()->json([ 'message' => 'Missing parameter.' ], 400); } public function destroy(Request $request) { if ($request->has('id')) { $watermark = $this->repository->find($request->id); if ($watermark) { $watermark->delete(); return response()->json([ 'message' => 'Watermark has been deleted.', 'watermarks' => $this->repository->getCollection() ]); } return response()->json([ 'message' => 'Watermark not found.' ], 404); } return response()->json([ 'message' => 'Missing parameter.' ], 400); } }