2024-02-29 13:00:59 -06:00
|
|
|
<?php
|
|
|
|
|
2024-05-09 11:24:12 -06:00
|
|
|
namespace App\Http\Controllers;
|
2024-02-29 13:00:59 -06:00
|
|
|
|
2024-03-05 13:27:27 -06:00
|
|
|
use App\Interfaces\PageRepositoryInterface;
|
2024-05-13 12:06:05 -06:00
|
|
|
use App\Interfaces\MemberRepositoryInterface;
|
2024-05-12 22:14:53 -06:00
|
|
|
use App\Services\Data\ThemeService;
|
|
|
|
use App\Services\Data\SortingService;
|
2024-03-01 13:34:36 -06:00
|
|
|
|
2024-05-09 11:24:12 -06:00
|
|
|
class DashController extends Controller
|
2024-02-29 13:00:59 -06:00
|
|
|
{
|
2024-03-05 13:27:27 -06:00
|
|
|
protected PageRepositoryInterface $pages;
|
2024-05-13 12:06:05 -06:00
|
|
|
protected MemberRepositoryInterface $member;
|
2024-03-06 10:27:41 -06:00
|
|
|
protected ThemeService $themes;
|
2024-03-19 13:19:27 -06:00
|
|
|
protected SortingService $sort;
|
2024-02-29 13:00:59 -06:00
|
|
|
|
2024-03-01 13:34:36 -06:00
|
|
|
public function __construct(
|
2024-03-05 13:27:27 -06:00
|
|
|
PageRepositoryInterface $pageRepository,
|
2024-05-13 12:06:05 -06:00
|
|
|
MemberRepositoryInterface $memberRepo,
|
2024-03-06 10:27:41 -06:00
|
|
|
ThemeService $themeService,
|
2024-03-19 13:19:27 -06:00
|
|
|
SortingService $sortingService
|
2024-03-01 13:34:36 -06:00
|
|
|
) {
|
2024-03-06 10:27:41 -06:00
|
|
|
$this->pages = $pageRepository;
|
2024-05-13 12:06:05 -06:00
|
|
|
$this->member = $memberRepo;
|
2024-03-06 10:27:41 -06:00
|
|
|
$this->themes = $themeService;
|
2024-03-19 13:19:27 -06:00
|
|
|
$this->sort = $sortingService;
|
2024-02-29 13:00:59 -06:00
|
|
|
}
|
|
|
|
|
2024-07-13 14:23:01 -06:00
|
|
|
//---
|
|
|
|
// GET
|
|
|
|
//---
|
|
|
|
|
2024-05-06 13:37:26 -06:00
|
|
|
public function init($second, $third, $fourth)
|
|
|
|
{
|
|
|
|
switch ($second) {
|
|
|
|
case 'settings':
|
|
|
|
return $this->settings();
|
|
|
|
break;
|
|
|
|
case 'navigation':
|
2024-05-06 15:18:05 -06:00
|
|
|
return $this->navigation();
|
2024-05-06 13:37:26 -06:00
|
|
|
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':
|
2024-05-09 11:24:12 -06:00
|
|
|
return $this->logout();
|
2024-05-06 13:37:26 -06:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return $this->start();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-03-03 19:50:14 -06:00
|
|
|
public function start()
|
2024-02-29 13:00:59 -06:00
|
|
|
{
|
2024-03-03 17:49:05 -06:00
|
|
|
$result = [];
|
2024-05-13 12:06:05 -06:00
|
|
|
if ($this->member::status()) {
|
2024-03-05 13:27:27 -06:00
|
|
|
$result = $this->pages->getGroup(1, 4);
|
2024-03-03 17:49:05 -06:00
|
|
|
}
|
2024-03-01 18:16:24 -06:00
|
|
|
return view('back.start', [
|
2024-05-13 12:06:05 -06:00
|
|
|
"status" => $this->member::status(),
|
2024-03-03 17:49:05 -06:00
|
|
|
"result" => $result,
|
2024-03-04 20:06:36 -06:00
|
|
|
"title" => "Start"
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2024-03-05 13:27:27 -06:00
|
|
|
public function book($pageFilter = 'all', $pageNum = 1)
|
|
|
|
{
|
|
|
|
$result = [];
|
2024-05-13 12:06:05 -06:00
|
|
|
if ($this->member::status()) {
|
2024-03-05 13:27:27 -06:00
|
|
|
$result = $this->pages->getGroup($pageNum, 4, $pageFilter);
|
|
|
|
}
|
|
|
|
return view('back.book', [
|
2024-06-04 14:58:55 -06:00
|
|
|
"status" => $this->member::status(),
|
2024-03-05 13:27:27 -06:00
|
|
|
"result" => $result,
|
|
|
|
"currentPage" => $pageNum,
|
|
|
|
"title" => "Pages"
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2024-03-05 15:49:30 -06:00
|
|
|
public function page($mode, $uuid)
|
2024-03-04 20:06:36 -06:00
|
|
|
{
|
2024-03-12 16:16:36 -06:00
|
|
|
$title;
|
|
|
|
$page = [];
|
|
|
|
$views = [];
|
2024-09-04 14:32:36 -06:00
|
|
|
$mode == 'edit' ? $page = $this->pages->getByUuid($uuid) : $page = [];
|
2024-03-12 16:16:36 -06:00
|
|
|
$mode == 'edit' ? $title = $page['title'] : $title = 'Add New';
|
|
|
|
$mode == 'edit' ? $views = $this->themes->getCustomViews($page['layout']) : $views[] = 'page';
|
2024-03-15 15:18:10 -06:00
|
|
|
|
2025-05-08 18:25:57 -06:00
|
|
|
//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'];
|
|
|
|
} else {
|
|
|
|
$id = "";
|
|
|
|
$uuid = "";
|
|
|
|
$slug = "";
|
|
|
|
$feature = "";
|
|
|
|
$layout = "";
|
|
|
|
$tags = "";
|
|
|
|
$content = "";
|
|
|
|
$date = "";
|
|
|
|
$updated = "";
|
|
|
|
$media = "";
|
|
|
|
$files = "";
|
|
|
|
};
|
|
|
|
|
2024-03-05 15:49:30 -06:00
|
|
|
return view('back.page', [
|
2025-05-08 18:25:57 -06:00
|
|
|
"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),
|
2024-03-01 18:16:24 -06:00
|
|
|
]);
|
2024-02-29 13:00:59 -06:00
|
|
|
}
|
2024-03-19 13:19:27 -06:00
|
|
|
|
2024-03-22 14:35:44 -06:00
|
|
|
public function navigation()
|
|
|
|
{
|
|
|
|
return view('back.navigation', $this->sort->navigation());
|
|
|
|
}
|
|
|
|
|
2024-03-19 13:19:27 -06:00
|
|
|
public function settings()
|
|
|
|
{
|
|
|
|
return view('back.settings', $this->sort->settings());
|
|
|
|
}
|
2024-05-09 11:24:12 -06:00
|
|
|
|
2024-07-13 14:23:01 -06:00
|
|
|
//---
|
|
|
|
// POST
|
|
|
|
//---
|
|
|
|
|
|
|
|
//---
|
|
|
|
// PUT
|
|
|
|
//---
|
|
|
|
|
|
|
|
//---
|
|
|
|
// AUTH
|
|
|
|
//---
|
|
|
|
|
|
|
|
public function login()
|
|
|
|
{
|
|
|
|
if ($this->member::status()) {
|
|
|
|
return redirect('dashboard');
|
|
|
|
} else {
|
|
|
|
return view('back.login', [
|
|
|
|
"status" => $this->member::status(),
|
|
|
|
"title" => "Hi!"
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-09 11:24:12 -06:00
|
|
|
public function logout()
|
|
|
|
{
|
|
|
|
session()->flush();
|
|
|
|
return redirect()->intended('dashboard');
|
|
|
|
}
|
2024-02-29 13:00:59 -06:00
|
|
|
}
|