forked from nanoninja/docker-nginx-php-mysql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAdminController.php
executable file
·65 lines (54 loc) · 1.55 KB
/
AdminController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
namespace Acme\Controllers;
use Acme\Models\Page;
use Cocur\Slugify\Slugify;
/**
* Class AdminController
* @package Acme\Controllers
*/
class AdminController extends BaseControllerWithDI {
/**
* Saved edited page; called via ajax
* @return string
*/
public function postSavePage()
{
$okay = true;
$page_id = $this->request->input('page_id');
$page_content = $this->request->input('thedata');
if ($page_id > 0) {
$page = Page::find($page_id);
} else {
$page = new Page;
$slugify = new Slugify;
$browser_title = $this->request->input('broswer_title');
$page->browser_title = $browser_title;
$page->slug = $slugify->slugify($browser_title);
$results = Page::where('slug', '=', $slugify->slugify($browser_title))->first();
if ($results)
$okay = false;
}
$page->page_content = $page_content;
if ($okay) {
$page->save();
echo "OK";
} else {
echo "Browser title is already in use!";
}
}
/**
* Add a page to db
*/
public function getAddPage()
{
$page_id = 0;
$page_content = "Enter your content here";
$browser_title = "";
return $this->response
->with('page_id', $page_id)
->with('browser_title', $browser_title)
->with('page_content', $page_content)
->withView('generic-page')
->render();
}
}