90 lines
2.7 KiB
PHP
90 lines
2.7 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use Illuminate\Http\Request;
|
|
use App\Services\Admin\ManageShortClipsService;
|
|
use App\Models\ManageShortClips;
|
|
use App\Models\ShortClipsLikes;
|
|
|
|
class ManageShortClipsController extends Controller
|
|
{
|
|
public function __construct(ManageShortClipsService $manageShortClipsService)
|
|
{
|
|
$this->manageShortClipsService = $manageShortClipsService;
|
|
}
|
|
|
|
public function create_short_clips()
|
|
{
|
|
return view('Admin.Pages.manage_short_clips.add_short_clips');
|
|
}
|
|
|
|
public function insert(Request $request)
|
|
{
|
|
try {
|
|
$shortClips = $this->manageShortClipsService->insert_short_clips($request);
|
|
if(!empty($shortClips))
|
|
{
|
|
return response()->json(['success' => true , 'status' => 200]);
|
|
}
|
|
else{
|
|
return response()->json(['success' => false , 'status' => 422]);
|
|
}
|
|
}
|
|
catch (Exception $e) {
|
|
echo 'Message: ' .$e->getMessage();
|
|
}
|
|
}
|
|
|
|
public function index(Request $request)
|
|
{
|
|
$data = $this->manageShortClipsService->get_all_short_clips();
|
|
return view('Admin.Pages.manage_short_clips.manage_short_clips')->with(['data'=>$data]);
|
|
}
|
|
|
|
public function destroy($id)
|
|
{
|
|
ManageShortClips::find($id)->delete();
|
|
}
|
|
|
|
public function edit_short_clips($id)
|
|
{
|
|
$data = $this->manageShortClipsService->edit_short_clips($id)->toArray();
|
|
return view('Admin.Pages.manage_short_clips.edit_short_clips')->with(['data'=>$data]);
|
|
|
|
}
|
|
|
|
public function update(Request $request)
|
|
{
|
|
try {
|
|
$data = $this->manageShortClipsService->update_short_clips($request);
|
|
if(!empty($data))
|
|
{
|
|
return response()->json(['success' => true , 'status' => 200]);
|
|
}
|
|
else{
|
|
return response()->json(['success' => false , 'status' => 422]);
|
|
}
|
|
}
|
|
catch (Exception $e) {
|
|
echo 'Message: ' .$e->getMessage();
|
|
}
|
|
|
|
}
|
|
|
|
public function changestatus(Request $request)
|
|
{
|
|
// print_r($request->status);
|
|
// exit;
|
|
$status = ManageShortClips::find($request->user_id);
|
|
$status->is_active = $request->status;
|
|
$status->save();
|
|
|
|
|
|
$changesSatus = ShortClipsLikes::where('short_clips_id', $request->user_id)->update(['is_active' => $request->status]);
|
|
|
|
return response()->json(['success'=>'Status change successfully.']);
|
|
|
|
}
|
|
} |