mirror of
https://github.com/Bigherollc/wticreatorstudio.git
synced 2026-07-14 09:01:42 -04:00
70 lines
1.8 KiB
PHP
70 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace Modules\StudioPlus\Http\Controllers\API;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Routing\Controller;
|
|
use Modules\StudioPlus\Http\Requests\StoreContentWatermarkRequest;
|
|
use Modules\StudioPlus\Repositories\ContentWatermarksRepository;
|
|
|
|
class StudioPlusWatermarkController extends Controller
|
|
{
|
|
protected $repository;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->repository = new ContentWatermarksRepository();
|
|
}
|
|
|
|
public function index(Request $request)
|
|
{
|
|
return $this->repository->getAll();
|
|
}
|
|
|
|
public function store(StoreContentWatermarkRequest $request)
|
|
{
|
|
$watermark = $this->repository->store($request);
|
|
|
|
if ($watermark) {
|
|
$watermark->load(['videoTypes']);
|
|
|
|
return response()->json([
|
|
'message' => 'Watermark has been saved.',
|
|
'watermark' => $watermark,
|
|
'watermarks' => $this->repository->getAll()
|
|
]);
|
|
}
|
|
|
|
return response()->json([
|
|
'message' => 'Failed to save watermark.'
|
|
], 400);
|
|
}
|
|
|
|
public function update(StoreContentWatermarkRequest $request)
|
|
{
|
|
$watermark = $this->repository->find($request->id);
|
|
|
|
if ($watermark) {
|
|
|
|
return response()->json([
|
|
'message' => 'Watermark has been updated.',
|
|
'watermark' => $this->repository->update($watermark, $request),
|
|
'watermarks' => $this->repository->getAll()
|
|
]);
|
|
}
|
|
|
|
return response()->json([
|
|
'message' => 'Watermark not found.'
|
|
], 404);
|
|
}
|
|
|
|
public function destroy(StudioPlusVideoType $videoType)
|
|
{
|
|
$videoType->delete();
|
|
|
|
Cache::forget('studio_plus_video_types');
|
|
|
|
return response()->noContent();
|
|
}
|
|
}
|