207 lines
5.7 KiB
PHP
207 lines
5.7 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Services\Api\ContentService;
|
|
use Illuminate\Http\Request;
|
|
|
|
class ContentController extends Controller
|
|
{
|
|
protected $contentService;
|
|
|
|
public function __construct(ContentService $contentService)
|
|
{
|
|
$this->contentService = $contentService;
|
|
}
|
|
|
|
// Promotions
|
|
public function promotionsIndex()
|
|
{
|
|
$response = $this->contentService->getAllPromotions();
|
|
|
|
if (!$response['success']) {
|
|
return back()->with('error', $response['message']);
|
|
}
|
|
|
|
return view('pages.promotions', [
|
|
'promotions' => $response['data']
|
|
]);
|
|
}
|
|
|
|
public function createPromotion()
|
|
{
|
|
return view('pages.add-promotions');
|
|
}
|
|
|
|
public function storePromotion(Request $request)
|
|
{
|
|
$response = $this->contentService->createPromotion($request->all());
|
|
|
|
if (!$response['success']) {
|
|
return back()->withInput()->with('error', $response['message']);
|
|
}
|
|
|
|
return redirect()->route('promotions.index')
|
|
->with('success', 'Promotion created successfully');
|
|
}
|
|
|
|
public function updatePromotion(Request $request, $id)
|
|
{
|
|
$response = $this->contentService->updatePromotion($id, $request->all());
|
|
|
|
if (!$response['success']) {
|
|
return back()->withInput()->with('error', $response['message']);
|
|
}
|
|
|
|
return redirect()->route('promotions.index')
|
|
->with('success', 'Promotion updated successfully');
|
|
}
|
|
|
|
public function deletePromotion($id)
|
|
{
|
|
$response = $this->contentService->deletePromotion($id);
|
|
|
|
if (!$response['success']) {
|
|
return back()->with('error', $response['message']);
|
|
}
|
|
|
|
return redirect()->route('promotions.index')
|
|
->with('success', 'Promotion deleted successfully');
|
|
}
|
|
|
|
// Notifications
|
|
public function notificationsIndex()
|
|
{
|
|
$response = $this->contentService->getAllNotifications();
|
|
|
|
if (!$response['success']) {
|
|
return back()->with('error', $response['message']);
|
|
}
|
|
|
|
return view('pages.notification', [
|
|
'notifications' => $response['data']
|
|
]);
|
|
}
|
|
|
|
public function createNotification()
|
|
{
|
|
return view('pages.add-notification');
|
|
}
|
|
|
|
public function storeNotification(Request $request)
|
|
{
|
|
$response = $this->contentService->createNotification($request->all());
|
|
|
|
if (!$response['success']) {
|
|
return back()->withInput()->with('error', $response['message']);
|
|
}
|
|
|
|
return redirect()->route('notifications.index')
|
|
->with('success', 'Notification created successfully');
|
|
}
|
|
|
|
public function updateNotification(Request $request, $id)
|
|
{
|
|
$response = $this->contentService->updateNotification($id, $request->all());
|
|
|
|
if (!$response['success']) {
|
|
return back()->withInput()->with('error', $response['message']);
|
|
}
|
|
|
|
return redirect()->route('notifications.index')
|
|
->with('success', 'Notification updated successfully');
|
|
}
|
|
|
|
public function deleteNotification($id)
|
|
{
|
|
$response = $this->contentService->deleteNotification($id);
|
|
|
|
if (!$response['success']) {
|
|
return back()->with('error', $response['message']);
|
|
}
|
|
|
|
return redirect()->route('notifications.index')
|
|
->with('success', 'Notification deleted successfully');
|
|
}
|
|
|
|
// Photo Slider
|
|
public function slidesIndex()
|
|
{
|
|
$response = $this->contentService->getAllSlides();
|
|
|
|
if (!$response['success']) {
|
|
return back()->with('error', $response['message']);
|
|
}
|
|
|
|
return view('pages.photo-slider', [
|
|
'slides' => $response['data']
|
|
]);
|
|
}
|
|
|
|
public function createSlide()
|
|
{
|
|
return view('pages.add-photo-slider');
|
|
}
|
|
|
|
public function storeSlide(Request $request)
|
|
{
|
|
$response = $this->contentService->createSlide($request->all());
|
|
|
|
if (!$response['success']) {
|
|
return back()->withInput()->with('error', $response['message']);
|
|
}
|
|
|
|
return redirect()->route('slides.index')
|
|
->with('success', 'Slide created successfully');
|
|
}
|
|
|
|
public function updateSlide(Request $request, $id)
|
|
{
|
|
$response = $this->contentService->updateSlide($id, $request->all());
|
|
|
|
if (!$response['success']) {
|
|
return back()->withInput()->with('error', $response['message']);
|
|
}
|
|
|
|
return redirect()->route('slides.index')
|
|
->with('success', 'Slide updated successfully');
|
|
}
|
|
|
|
public function deleteSlide($id)
|
|
{
|
|
$response = $this->contentService->deleteSlide($id);
|
|
|
|
if (!$response['success']) {
|
|
return back()->with('error', $response['message']);
|
|
}
|
|
|
|
return redirect()->route('slides.index')
|
|
->with('success', 'Slide deleted successfully');
|
|
}
|
|
|
|
// Terms and Privacy
|
|
public function termsAndPrivacy()
|
|
{
|
|
$response = $this->contentService->getTermsAndPrivacy();
|
|
|
|
if (!$response['success']) {
|
|
return back()->with('error', $response['message']);
|
|
}
|
|
|
|
return view('pages.add-terms-and-privacy', [
|
|
'content' => $response['data']
|
|
]);
|
|
}
|
|
|
|
public function updateTermsAndPrivacy(Request $request)
|
|
{
|
|
$response = $this->contentService->updateTermsAndPrivacy($request->all());
|
|
|
|
if (!$response['success']) {
|
|
return back()->withInput()->with('error', $response['message']);
|
|
}
|
|
|
|
return redirect()->route('terms-and-privacy.index')
|
|
->with('success', 'Terms and Privacy updated successfully');
|
|
}
|
|
}
|