mirror of
https://github.com/Bigherollc/wticreatorstudio.git
synced 2026-10-16 18:13:00 -04:00
Initial commit
This commit is contained in:
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\StudioPlus\Http\Controllers\API;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Controller;
|
||||
use Modules\StudioPlus\Entities\ContentWatermark;
|
||||
use Modules\StudioPlus\Http\Requests\StoreContentWatermarkRequest;
|
||||
use Modules\StudioPlus\Repositories\ContentWatermarksRepository;
|
||||
use Modules\StudioPlus\Transformers\ContentWatermarkDatabaseResource;
|
||||
use Modules\StudioPlus\Transformers\ContentWatermarkRequestResource;
|
||||
|
||||
class ContentWatermarksController extends Controller
|
||||
{
|
||||
protected $repository;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user