Files
freeu-project/app/Http/Controllers/PrivacypolicyController.php
2024-04-09 17:56:07 +05:30

99 lines
3.0 KiB
PHP

<?php
namespace App\Http\Controllers;
use App\Models\Content;
use App\Traits\HttpResponse;
use App\Http\Resources\PrivacyResource;
use App\Http\Resources\TermsConditionResource;
use App\Http\Requests\UpdatePrivacyPolicyRequest;
use App\Http\Requests\UpdateTermsAndConditionsRequest;
use App\Services\Admin\PrivacyPolicyTermsConditionsService;
class PrivacypolicyController extends Controller
{
use HttpResponse;
protected $content;
public function __construct(PrivacyPolicyTermsConditionsService $content)
{
$this->content = $content;
}
public function privacyData()
{
$check = checkSidebarAccess('privacy-policy');
if (!$check) {
abort(404);
}
return view('Admin.Pages.manage_cms.manage_Privacy_policy.privacy', [
'data' => $this->content->privacyPolicy()
]);
}
public function privacyEdit($type)
{
return view('Admin.Pages.manage_cms.manage_Privacy_policy.edit_privacy_policy', [
'data' => $this->content->privacyPolicy()
]);
}
public function privacyUpdate(UpdatePrivacyPolicyRequest $request)
{
$privacyPolicyUpdated = $this->content->updatePrivacy($request);
return $privacyPolicyUpdated ?
$this->response('Privacy Policy Updated', 200) :
$this->response('Could Not Update Privacy Policy', 400);
}
public function privacyPolicyApi()
{
try {
return (new PrivacyResource(Content::where('type', 'privacy-policy')->first()))
->response()
->setStatusCode(200);
} catch (\Exception $e) {
return response()->json(['message' => $e->getMessage()], 400);
}
}
//====================================================Terms and Controller===================================================================//
public function termsData()
{
$check = checkSidebarAccess('terms-and-conditions');
if (!$check) {
abort(404);
}
return view('Admin.Pages.manage_cms.manage_Privacy_policy.privacy', [
'data' => $this->content->termsCondition()
]);
}
public function termsEdit()
{
return view('Admin.Pages.manage_cms.manage_Privacy_policy.edit_privacy_policy', [
'data' => $this->content->termsCondition()
]);
}
public function termsUpdate(UpdateTermsAndConditionsRequest $request)
{
$termsAndConditionsUpdated = $this->content->updateTerms($request);
return $termsAndConditionsUpdated ?
$this->response('Terms and Conditions Updated', 200) :
$this->response('Could Not Update Terms and Conditions', 400);
}
public function termsConditionApi()
{
try {
return (new TermsConditionResource(Content::where('type', 'terms-and-condition')->first()))
->response()
->setStatusCode(200);
} catch (\Exception $e) {
return response()->json(['message' => $e->getMessage()], 400);
}
}
}