63 lines
1.9 KiB
PHP
63 lines
1.9 KiB
PHP
<?php
|
|
namespace App\Http\Controllers\Admin\Contents;
|
|
|
|
use App\CMS\Enumerations\ContentStatuses;
|
|
use App\Http\Controllers\Admin\Controller;
|
|
use App\Models\Content\Content;
|
|
use App\Models\Module;
|
|
use Illuminate\Support\Facades\Input;
|
|
|
|
class ContentOverview extends Controller
|
|
{
|
|
/**
|
|
* @var Content
|
|
*/
|
|
private $content;
|
|
|
|
public function __construct(Content $content)
|
|
{
|
|
parent::__construct();
|
|
|
|
$this->content = $content;
|
|
}
|
|
|
|
/**
|
|
* Overview for all content pages.
|
|
*
|
|
* @param bool|false $moduleId
|
|
* @param null $status
|
|
*
|
|
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
|
*/
|
|
public function getOverview($moduleId = false, $status = null)
|
|
{
|
|
$moduleFilterHandler = false;
|
|
$perPage = Input::get('perPage') ? Input::get('perPage') : 20;
|
|
$pageHeading = 'admin/contents.overview';
|
|
|
|
// does user want to filter results using module?
|
|
if (is_numeric($moduleId)) {
|
|
$module = Module::findOrFail($moduleId);
|
|
$moduleFilterHandler = $module->handler;
|
|
|
|
if (is_callable([$module->handler, 'getOverviewTitle'])) {
|
|
$pageHeading = call_user_func([$module->handler, 'getOverviewTitle']);
|
|
}
|
|
}
|
|
|
|
// get pages for overview
|
|
$pages = $this->content->getOverview($moduleFilterHandler, $status, true, true)
|
|
->paginate($perPage);
|
|
|
|
// get homepage - for checking if homepage is set and available
|
|
$homepage = $this->content->getHomepage();
|
|
|
|
return view('admin.content.overview', [
|
|
'pages' => $pages,
|
|
'homepage' => $homepage,
|
|
'pageHeading' => $pageHeading,
|
|
'statuses' => ContentStatuses::getWithTranslations(),
|
|
'module' => isset($module) ? $module : null
|
|
]);
|
|
}
|
|
} |