fipamo/app/Http/Controllers/DashController.php
ro b527884c51
added theme service class
page editing was missing the selector to choose what template the page
was using, so a theme class was created to handle retrieving and sorting
what classes where avaiable in the themes directory

still looking for twig files because themes haven't been converted over
yet, but one step at a time
2024-03-06 10:27:41 -06:00

64 lines
1.7 KiB
PHP

<?php
namespace App\Http\Controllers;
use App\Interfaces\PageRepositoryInterface;
use App\Services\AuthService;
use App\Services\ThemeService;
class DashController extends Controller
{
protected PageRepositoryInterface $pages;
protected AuthService $auth;
protected ThemeService $themes;
public function __construct(
PageRepositoryInterface $pageRepository,
AuthService $authService,
ThemeService $themeService,
) {
$this->pages = $pageRepository;
$this->auth = $authService;
$this->themes = $themeService;
}
public function start()
{
$result = [];
if ($this->auth::status()) {
$result = $this->pages->getGroup(1, 4);
}
return view('back.start', [
"status" => $this->auth::status(),
"result" => $result,
"title" => "Start"
]);
}
public function book($pageFilter = 'all', $pageNum = 1)
{
$result = [];
if ($this->auth::status()) {
$result = $this->pages->getGroup($pageNum, 4, $pageFilter);
}
return view('back.book', [
"status" => $this->auth::status(),
"result" => $result,
"currentPage" => $pageNum,
"title" => "Pages"
]);
}
public function page($mode, $uuid)
{
$page = $this->pages->getById($uuid)->first();
return view('back.page', [
"status" => $this->auth::status(),
"mode" => $mode,
"page" => $page,
"views" => $this->themes->getCustomViews($page['layout']),
"title" => 'Editing ' . $page['title']
]);
}
}