1
|
|
|
<?php namespace Arcanesoft\Seo\Http\Controllers\Admin; |
2
|
|
|
|
3
|
|
|
use Arcanesoft\Seo\Entities\Locales; |
4
|
|
|
use Arcanesoft\Seo\Http\Requests\Admin\Pages\CreatePageRequest; |
5
|
|
|
use Arcanesoft\Seo\Http\Requests\Admin\Pages\UpdatePageRequest; |
6
|
|
|
use Arcanesoft\Seo\Models\Page; |
7
|
|
|
use Illuminate\Support\Facades\Log; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Class PagesController |
11
|
|
|
* |
12
|
|
|
* @package Arcanesoft\Seo\Http\Controllers\Admin |
13
|
|
|
* @author ARCANEDEV <[email protected]> |
14
|
|
|
* |
15
|
|
|
* @todo: Add authorization checks |
16
|
|
|
*/ |
17
|
|
|
class PagesController extends Controller |
18
|
|
|
{ |
19
|
|
|
/* ----------------------------------------------------------------- |
20
|
|
|
| Constructor |
21
|
|
|
| ----------------------------------------------------------------- |
22
|
|
|
*/ |
23
|
|
|
/** |
24
|
|
|
* PagesController constructor. |
25
|
|
|
*/ |
26
|
|
|
public function __construct() |
27
|
|
|
{ |
28
|
|
|
parent::__construct(); |
29
|
|
|
|
30
|
|
|
$this->setCurrentPage('seo-pages'); |
31
|
|
|
$this->addBreadcrumbRoute('Pages', 'admin::seo.pages.index'); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/* ----------------------------------------------------------------- |
35
|
|
|
| Main Methods |
36
|
|
|
| ----------------------------------------------------------------- |
37
|
|
|
*/ |
38
|
|
|
public function index() |
39
|
|
|
{ |
40
|
|
|
$this->setTitle($title = 'List of Pages'); |
41
|
|
|
$this->addBreadcrumb($title); |
42
|
|
|
|
43
|
|
|
$pages = Page::with(['footers'])->paginate(50); |
44
|
|
|
|
45
|
|
|
return $this->view('admin.pages.index', compact('pages')); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function create() |
49
|
|
|
{ |
50
|
|
|
$this->setTitle($title = 'New Page'); |
51
|
|
|
$this->addBreadcrumb($title); |
52
|
|
|
|
53
|
|
|
$locales = Locales::all(); |
54
|
|
|
|
55
|
|
|
return $this->view('admin.pages.create', compact('locales')); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public function store(CreatePageRequest $request) |
59
|
|
|
{ |
60
|
|
|
$page = Page::createOne( |
61
|
|
|
$request->only(['name', 'locale', 'content']) |
62
|
|
|
); |
63
|
|
|
|
64
|
|
|
$message = "The page was created successfully !"; |
65
|
|
|
Log::info($message, $page->toArray()); |
66
|
|
|
$this->notifySuccess($message, 'Page created !'); |
67
|
|
|
|
68
|
|
|
return redirect()->route('admin::seo.pages.show', [$page]); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
public function show(Page $page) |
72
|
|
|
{ |
73
|
|
|
$this->setTitle($title = 'Page details'); |
74
|
|
|
$this->addBreadcrumb($title); |
75
|
|
|
|
76
|
|
|
$page->load(['footers.seo']); |
77
|
|
|
|
78
|
|
|
return $this->view('admin.pages.show', compact('page')); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
public function edit(Page $page) |
82
|
|
|
{ |
83
|
|
|
$this->setTitle($title = 'Edit Page'); |
84
|
|
|
$this->addBreadcrumb($title); |
85
|
|
|
|
86
|
|
|
$locales = Locales::all(); |
87
|
|
|
|
88
|
|
|
return $this->view('admin.pages.edit', compact('page', 'locales')); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
public function update(Page $page, UpdatePageRequest $request) |
92
|
|
|
{ |
93
|
|
|
$page->updateOne( |
94
|
|
|
$request->only(['name', 'locale', 'content']) |
95
|
|
|
); |
96
|
|
|
|
97
|
|
|
$message = "The page was updated successfully !"; |
98
|
|
|
Log::info($message, $page->toArray()); |
99
|
|
|
$this->notifySuccess($message, 'Page updated !'); |
100
|
|
|
|
101
|
|
|
return redirect()->route('admin::seo.pages.show', [$page]); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
public function delete(Page $page) |
105
|
|
|
{ |
106
|
|
|
// |
107
|
|
|
} |
108
|
|
|
} |
109
|
|
|
|