moved page meta data to it's own ui to clean up the page editing experience as it was becoming a bit crowded. also moved to saving and deleting buttons to title bar so they are always available added a note to web routes to reorganize them within the web routes file to reduce the confusion present by having them in their own Controllers. it's just an extra layer that's not needed
184 lines
5 KiB
PHP
184 lines
5 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Interfaces\PageRepositoryInterface;
|
|
use App\Interfaces\MemberRepositoryInterface;
|
|
use App\Services\Data\ThemeService;
|
|
use App\Services\Data\SortingService;
|
|
|
|
class DashController extends Controller
|
|
{
|
|
protected PageRepositoryInterface $pages;
|
|
protected MemberRepositoryInterface $member;
|
|
protected ThemeService $themes;
|
|
protected SortingService $sort;
|
|
|
|
public function __construct(
|
|
PageRepositoryInterface $pageRepository,
|
|
MemberRepositoryInterface $memberRepo,
|
|
ThemeService $themeService,
|
|
SortingService $sortingService
|
|
) {
|
|
$this->pages = $pageRepository;
|
|
$this->member = $memberRepo;
|
|
$this->themes = $themeService;
|
|
$this->sort = $sortingService;
|
|
}
|
|
|
|
//---
|
|
// GET
|
|
//---
|
|
|
|
public function init($second, $third, $fourth)
|
|
{
|
|
switch ($second) {
|
|
case 'settings':
|
|
return $this->settings();
|
|
break;
|
|
case 'navigation':
|
|
return $this->navigation();
|
|
break;
|
|
case 'pages':
|
|
($third == null) ? $third = 'all' : $third = $third;
|
|
($fourth == null) ? $fourth = 1 : $fourth = $fourth;
|
|
return $this->book($third, $fourth);
|
|
break;
|
|
case 'page':
|
|
return $this->page($third, $fourth);
|
|
break;
|
|
case 'logout':
|
|
return $this->logout();
|
|
break;
|
|
default:
|
|
return $this->start();
|
|
break;
|
|
}
|
|
}
|
|
|
|
public function start()
|
|
{
|
|
$result = [];
|
|
if ($this->member::status()) {
|
|
$result = $this->pages->getGroup(1, 4);
|
|
}
|
|
return view('back.start', [
|
|
"status" => $this->member::status(),
|
|
"result" => $result,
|
|
"title" => "Start"
|
|
]);
|
|
}
|
|
|
|
public function book($pageFilter = 'all', $pageNum = 1)
|
|
{
|
|
$result = [];
|
|
if ($this->member::status()) {
|
|
$result = $this->pages->getGroup($pageNum, 4, $pageFilter);
|
|
}
|
|
return view('back.book', [
|
|
"status" => $this->member::status(),
|
|
"result" => $result,
|
|
"currentPage" => $pageNum,
|
|
"title" => "Pages"
|
|
]);
|
|
}
|
|
|
|
public function page($mode, $uuid)
|
|
{
|
|
$title;
|
|
$page = [];
|
|
$views = [];
|
|
$mode == 'edit' ? $page = $this->pages->getByUuid($uuid) : $page = [];
|
|
$mode == 'edit' ? $title = 'Edit Page' : $title = 'Add New';
|
|
$mode == 'edit' ? $views = $this->themes->getCustomViews($page['layout']) : $views[] = 'page';
|
|
|
|
//just a patch for now to get this out of the template
|
|
if ($mode == 'edit') {
|
|
$id = $page['id'];
|
|
$uuid = $page['uuid'];
|
|
$slug = $page['slug'];
|
|
$feature = $page['feature'];
|
|
$layout = $page['layout'];
|
|
$tags = $page['tags'];
|
|
$content = $page['content'];
|
|
$date = $page['created'];
|
|
$updated = $page['updated'];
|
|
$media = $page['media'];
|
|
$files = $page['docs'];
|
|
$editTitle = $page['title'];
|
|
} else {
|
|
$id = "";
|
|
$uuid = "";
|
|
$slug = "";
|
|
$feature = "";
|
|
$layout = "";
|
|
$tags = "";
|
|
$content = "";
|
|
$date = "";
|
|
$updated = "";
|
|
$media = "";
|
|
$files = "";
|
|
$editTitle = "";
|
|
};
|
|
|
|
return view('back.page', [
|
|
"status" => $this->member::status(),
|
|
"mode" => $mode,
|
|
"page" => $page,
|
|
"views" => $views,
|
|
"id" => $id,
|
|
"uuid" => $uuid,
|
|
"slug" => $slug,
|
|
"feature" => $feature,
|
|
"layout" => $layout,
|
|
"tags" => $tags,
|
|
"content" => $content,
|
|
"date" => $date,
|
|
"updated" => $updated,
|
|
"media" => $media,
|
|
"files" => $files,
|
|
"title" => urldecode($title),
|
|
"editTitle" => urldecode($editTitle),
|
|
]);
|
|
}
|
|
|
|
public function navigation()
|
|
{
|
|
return view('back.navigation', $this->sort->navigation());
|
|
}
|
|
|
|
public function settings()
|
|
{
|
|
return view('back.settings', $this->sort->settings());
|
|
}
|
|
|
|
//---
|
|
// POST
|
|
//---
|
|
|
|
//---
|
|
// PUT
|
|
//---
|
|
|
|
//---
|
|
// AUTH
|
|
//---
|
|
|
|
public function login()
|
|
{
|
|
if ($this->member::status()) {
|
|
return redirect('dashboard');
|
|
} else {
|
|
return view('back.login', [
|
|
"status" => $this->member::status(),
|
|
"title" => "Hi!"
|
|
]);
|
|
}
|
|
}
|
|
|
|
public function logout()
|
|
{
|
|
session()->flush();
|
|
return redirect()->intended('dashboard');
|
|
}
|
|
}
|