FEATURE: split controllers/admin into more smaller directories

This commit is contained in:
Michal Kváček
2016-09-22 23:35:53 +02:00
parent 0357417163
commit 139373145a
41 changed files with 374 additions and 412 deletions
@@ -0,0 +1,63 @@
<?php
namespace App\Http\Controllers\Admin\Contents;
use App\Enumerations\ContentStatuses;
use App\Http\Controllers\Admin\Controller;
use App\Models\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
]);
}
}