mirror of
https://github.com/Bigherollc/wticreatorstudio.git
synced 2026-07-14 09:01:42 -04:00
82 lines
2.1 KiB
PHP
82 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace Modules\StudioPlus\Http\Controllers\API;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Response;
|
|
use Illuminate\Routing\Controller;
|
|
use Modules\StudioPlus\Entities\StudioPlusComment;
|
|
use Modules\StudioPlus\Entities\StudioPlusVideo;
|
|
use Modules\StudioPlus\Http\Requests\StudioPlusCommentRequest;
|
|
|
|
class StudioPlusCommentController extends Controller
|
|
{
|
|
/**
|
|
* Display a listing of the resource.
|
|
* @return Response
|
|
*/
|
|
public function index(Request $request, StudioPlusVideo $studioPlusVideo)
|
|
{
|
|
|
|
return StudioPlusComment::with('user')
|
|
->where('studio_plus_video_id', $studioPlusVideo->id)
|
|
->when(!in_array(auth()->user()->role->type, ['superadmin', 'admin']), fn ($query) => $query->where('user_id', auth()->id()))
|
|
->latest()
|
|
->get();
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Store a newly created resource in storage.
|
|
* @param Request $request
|
|
* @return Response
|
|
*/
|
|
public function store(StudioPlusCommentRequest $request, StudioPlusVideo $studioPlusVideo)
|
|
{
|
|
$validated = $request->validated();
|
|
$validated['studio_plus_video_id'] = $studioPlusVideo->id;
|
|
$validated['user_id'] = auth()->id();
|
|
// dd($validated);
|
|
StudioPlusComment::create($validated);
|
|
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Show the specified resource.
|
|
* @param int $id
|
|
* @return Response
|
|
*/
|
|
public function show($id)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Update the specified resource in storage.
|
|
* @param Request $request
|
|
* @param int $id
|
|
* @return Response
|
|
*/
|
|
public function update(StudioPlusCommentRequest $request, StudioPlusComment $comment)
|
|
{
|
|
$comment->update($request->validated());
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Remove the specified resource from storage.
|
|
* @param int $id
|
|
* @return Response
|
|
*/
|
|
public function destroy(StudioPlusComment $comment)
|
|
{
|
|
|
|
// // dd($validated);
|
|
// StudioPlusComment::create($validated);
|
|
$comment->delete();
|
|
|
|
return response()->noContent();
|
|
}
|
|
}
|