mirror of
https://github.com/Bigherollc/wticreatorstudio.git
synced 2026-01-16 19:05:08 -05:00
86 lines
3.3 KiB
PHP
86 lines
3.3 KiB
PHP
<?php
|
|
|
|
namespace Modules\Subscription\Http\Controllers;
|
|
|
|
use Illuminate\Contracts\Support\Renderable;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Routing\Controller;
|
|
use Modules\Subscription\Http\Requests\LocationRestrictionFormRequest;
|
|
use Modules\Subscription\Repositories\LocationRestrictionsRepository;
|
|
use Modules\UserActivityLog\Traits\LogActivity;
|
|
use Brian2694\Toastr\Facades\Toastr;
|
|
|
|
class LocationRestrictionsController extends Controller
|
|
{
|
|
private $locationRestrictionsRepository;
|
|
|
|
public function __construct(LocationRestrictionsRepository $locationRestrictionsRepository)
|
|
{
|
|
$this->locationRestrictionsRepository = $locationRestrictionsRepository;
|
|
}
|
|
|
|
public function get_list()
|
|
{
|
|
$data['locations'] = $this->locationRestrictionsRepository->getAll();
|
|
return view('subscription::setting.locations.list', $data);
|
|
}
|
|
|
|
public function store(LocationRestrictionFormRequest $request)
|
|
{
|
|
try {
|
|
$this->locationRestrictionsRepository->create($request->except("_token"));
|
|
LogActivity::successLog('Subscription location restriction Added.');
|
|
return response()->json(["message" => "Subscription Location Restriction Added Successfully"], 200);
|
|
} catch (\Exception $e) {
|
|
LogActivity::errorLog($e->getMessage());
|
|
return response()->json(["message" => "Something Went Wrong", "error" => $e->getMessage()], 503);
|
|
}
|
|
}
|
|
|
|
public function edit($id)
|
|
{
|
|
try {
|
|
$location = $this->locationRestrictionsRepository->find($id);
|
|
return view('subscription::setting.locations.edit', compact('location'));
|
|
} catch (\Exception $e) {
|
|
LogActivity::errorLog($e->getMessage());
|
|
return response()->json(["message" => "Something Went Wrong", "error" => $e->getMessage()], 503);
|
|
}
|
|
}
|
|
|
|
public function update(LocationRestrictionFormRequest $request, $id)
|
|
{
|
|
try {
|
|
$this->locationRestrictionsRepository->update($request->except("_token"), $id);
|
|
LogActivity::successLog('Subscription Location Restriction Updated.');
|
|
return response()->json([
|
|
"message" => "Subscription Location Restriction Updated Successfully",
|
|
"createForm" => (string)view('subscription::setting.locations.add')
|
|
], 200);
|
|
} catch (\Exception $e) {
|
|
dd($e);
|
|
LogActivity::errorLog($e->getMessage());
|
|
return response()->json(["message" => "Something Went Wrong", "error" => $e->getMessage()], 503);
|
|
}
|
|
}
|
|
|
|
public function destroy($id)
|
|
{
|
|
try {
|
|
$result = $this->locationRestrictionsRepository->delete($id);
|
|
if ($result == "not_possible") {
|
|
Toastr::warning(__('Unable to delete location restriction.'));
|
|
return back();
|
|
} else {
|
|
LogActivity::successLog('Subscription Location Restriction Deleted.');
|
|
Toastr::success(__('common.deleted_successfully'), __('common.success'));
|
|
return back();
|
|
}
|
|
} catch (\Exception $e) {
|
|
LogActivity::errorLog($e->getMessage());
|
|
Toastr::error(__('common.Something Went Wrong'));
|
|
return back();
|
|
}
|
|
}
|
|
}
|