2024-02-29 20:00:59 +01:00
|
|
|
<?php
|
|
|
|
|
2024-03-07 18:36:31 +01:00
|
|
|
namespace App\Http\Controllers\Dash;
|
2024-02-29 20:00:59 +01:00
|
|
|
|
2024-03-05 20:27:27 +01:00
|
|
|
use App\Interfaces\PageRepositoryInterface;
|
2024-03-06 16:50:09 +01:00
|
|
|
use App\Services\AuthService;
|
2024-03-06 17:27:41 +01:00
|
|
|
use App\Services\ThemeService;
|
2024-03-07 18:36:31 +01:00
|
|
|
use App\Http\Controllers\Controller;
|
2024-03-01 20:34:36 +01:00
|
|
|
|
2024-03-07 18:36:31 +01:00
|
|
|
class IndexController extends Controller
|
2024-02-29 20:00:59 +01:00
|
|
|
{
|
2024-03-05 20:27:27 +01:00
|
|
|
protected PageRepositoryInterface $pages;
|
2024-03-06 16:50:09 +01:00
|
|
|
protected AuthService $auth;
|
2024-03-06 17:27:41 +01:00
|
|
|
protected ThemeService $themes;
|
2024-02-29 20:00:59 +01:00
|
|
|
|
2024-03-01 20:34:36 +01:00
|
|
|
public function __construct(
|
2024-03-05 20:27:27 +01:00
|
|
|
PageRepositoryInterface $pageRepository,
|
2024-03-06 16:50:09 +01:00
|
|
|
AuthService $authService,
|
2024-03-06 17:27:41 +01:00
|
|
|
ThemeService $themeService,
|
2024-03-01 20:34:36 +01:00
|
|
|
) {
|
2024-03-06 17:27:41 +01:00
|
|
|
$this->pages = $pageRepository;
|
|
|
|
$this->auth = $authService;
|
|
|
|
$this->themes = $themeService;
|
2024-02-29 20:00:59 +01:00
|
|
|
}
|
|
|
|
|
2024-03-07 18:36:31 +01:00
|
|
|
public function login()
|
|
|
|
{
|
|
|
|
if ($this->auth::status()) {
|
|
|
|
return redirect('dashboard/start');
|
|
|
|
} else {
|
|
|
|
return view('back.login', [
|
|
|
|
"status" => $this->auth::status(),
|
|
|
|
"title" => "Hi!"
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-03-04 02:50:14 +01:00
|
|
|
public function start()
|
2024-02-29 20:00:59 +01:00
|
|
|
{
|
2024-03-04 00:49:05 +01:00
|
|
|
$result = [];
|
2024-03-06 16:50:09 +01:00
|
|
|
if ($this->auth::status()) {
|
2024-03-05 20:27:27 +01:00
|
|
|
$result = $this->pages->getGroup(1, 4);
|
2024-03-04 00:49:05 +01:00
|
|
|
}
|
2024-03-02 01:16:24 +01:00
|
|
|
return view('back.start', [
|
2024-03-06 16:50:09 +01:00
|
|
|
"status" => $this->auth::status(),
|
2024-03-04 00:49:05 +01:00
|
|
|
"result" => $result,
|
2024-03-05 03:06:36 +01:00
|
|
|
"title" => "Start"
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2024-03-05 20:27:27 +01:00
|
|
|
public function book($pageFilter = 'all', $pageNum = 1)
|
|
|
|
{
|
|
|
|
$result = [];
|
2024-03-06 16:50:09 +01:00
|
|
|
if ($this->auth::status()) {
|
2024-03-05 20:27:27 +01:00
|
|
|
$result = $this->pages->getGroup($pageNum, 4, $pageFilter);
|
|
|
|
}
|
|
|
|
return view('back.book', [
|
2024-03-06 16:50:09 +01:00
|
|
|
"status" => $this->auth::status(),
|
2024-03-05 20:27:27 +01:00
|
|
|
"result" => $result,
|
|
|
|
"currentPage" => $pageNum,
|
|
|
|
"title" => "Pages"
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2024-03-05 22:49:30 +01:00
|
|
|
public function page($mode, $uuid)
|
2024-03-05 03:06:36 +01:00
|
|
|
{
|
2024-03-12 23:16:36 +01:00
|
|
|
$title;
|
|
|
|
$page = [];
|
|
|
|
$views = [];
|
|
|
|
$mode == 'edit' ? $page = $this->pages->getById($uuid)->first() : $page = [];
|
|
|
|
$mode == 'edit' ? $title = $page['title'] : $title = 'Add New';
|
|
|
|
$mode == 'edit' ? $views = $this->themes->getCustomViews($page['layout']) : $views[] = 'page';
|
2024-03-05 22:49:30 +01:00
|
|
|
return view('back.page', [
|
2024-03-06 16:50:09 +01:00
|
|
|
"status" => $this->auth::status(),
|
2024-03-05 22:49:30 +01:00
|
|
|
"mode" => $mode,
|
|
|
|
"page" => $page,
|
2024-03-12 23:16:36 +01:00
|
|
|
"views" => $views,
|
|
|
|
"title" => $title,
|
2024-03-02 01:16:24 +01:00
|
|
|
]);
|
2024-02-29 20:00:59 +01:00
|
|
|
}
|
|
|
|
}
|