Permalink
Browse files

Admin Pages - add featured order and fix redirect on edit page conten…

…t submit
  • Loading branch information...
bpocallaghan committed Jun 1, 2018
1 parent 0e72ddb commit ef81bba28b10996384cbe45aa22a3dede29132e5
@@ -12,13 +12,13 @@
class OrderController extends TitanAdminController
{
private $navigationType = 'main';
private $navigationType = 'list';
private $defaultParent = 0;
private $orderProperty = 'header_order';
private function updateNavType($type = 'all')
private function updateNavType($type = 'list')
{
$this->defaultParent = 0;
$this->navigationType = $type;
@@ -31,7 +31,7 @@ private function updateNavType($type = 'all')
* @param string $type
* @return Response
*/
public function index($type = 'all')
public function index($type = 'list')
{
$this->updateNavType($type);
@@ -47,7 +47,7 @@ public function index($type = 'all')
* @param Request $request
* @return array
*/
public function updateOrder(Request $request, $type = 'main')
public function updateOrder(Request $request, $type = 'list')
{
$this->updateNavType($type);
@@ -76,14 +76,17 @@ private function getNavigationHtml($parent = null)
$html = '<ol class="dd-list">';
$parentId = ($parent ? $parent->id : 0);
$items = Page::whereParentIdORM($parentId, $this->navigationType,
$this->orderProperty);
$items = Page::whereParentIdORM($parentId, $this->navigationType, $this->orderProperty);
foreach ($items as $key => $nav) {
$html .= '<li class="dd-item" data-id="' . $nav->id . '">';
$html .= '<div class="dd-handle">' . '<i class="fa-fw fa fa-' . $nav->icon . '"></i> ';
$html .= $nav->title . ' ' . ($nav->is_hidden == 1 ? '(HIDDEN)' : '') . ' <span style="float:right"> ' . $nav->url . ' </span></div>';
$html .= $this->getNavigationHtml($nav);
// featured - ignore parent_id (only one level)
if ($this->orderProperty != "featured_order") {
$html .= $this->getNavigationHtml($nav);
}
$html .= '</li>';
}
@@ -82,6 +82,12 @@ public function show(Page $page)
*/
public function edit(Page $page)
{
// fix for when you
// edit sections from the edit page
// or delete photo/document then
// need to update resource url
save_resource_url();
$parents = Page::getAllList();
$banners = Banner::getAllList();
@@ -37,23 +37,28 @@ public function urlParent()
*/
static public function whereParentIdORM(
$id,
$type = 'header',
$order = 'header_order',
$type = 'list',
$order = 'list_order',
$hidden = 0
) {
$query = self::whereParentId($id);
$query = Page::query();
if($type != "featured") {
$query->whereParentId($id);
}
switch ($type) {
case 'all':
$order = 'header_order';
$query->where('is_header', 0);
$query->where('is_footer', 0);
case "header":
$query->where('is_header', 1);
break;
case 'footer';
case "footer";
$query->where('is_footer', 1);
break;
case "featured":
$query->where('is_featured', 1);
break;
default:
$query->where('is_header', 1);
$query->where('is_header', 0);
$query->where('is_footer', 0);
}
return $query->orderBy($order)->get();
@@ -65,8 +70,6 @@ static public function whereParentIdORM(
* Get the url from db
* If true given, we generate a new one,
* This us usefull if parent_id updated, etc
*
* @return \Eloquent
*/
public function updateUrl()
{
@@ -208,7 +211,7 @@ public static function getHeaderNavigation()
public static function getFeatured()
{
return self::where('is_featured', 1)->orderBy('name')->get();
return self::where('is_featured', 1)->orderBy('featured_order')->get();
}
public static function getHeaderNavigationRight()
@@ -20,12 +20,14 @@ public function up()
$table->string('slug')->nullable();
$table->string('url')->nullable();
$table->string('icon')->nullable();
$table->integer('list_order')->nullable();
$table->boolean('is_header')->nullable();
$table->integer('header_order')->default(99);
$table->integer('header_order')->nullable();
$table->boolean('is_footer')->nullable();
$table->integer('footer_order')->nullable();
$table->boolean('is_hidden')->default(0);
$table->boolean('is_featured')->nullable();
$table->integer('featured_order')->nullable();
$table->integer('parent_id')->unsigned()->default(0);
$table->integer('url_parent_id')->unsigned()->default(0);
$table->unsignedBigInteger('views')->default(0);
@@ -24,13 +24,18 @@
<span class="btn-label"><i class="fa fa-fw fa-align-center"></i></span>General Order
</a>
<a class="btn btn-labeled btn-default text-black" href="{{ Request::url().'/order/featured' }}">
<span class="btn-label"><i class="fa fa-fw fa-align-center"></i></span>
Featured Order
</a>
<a class="btn btn-labeled btn-default text-black" href="{{ request()->url().'/order/header' }}">
<span class="btn-label"><i class="fa fa-fw fa-align-center"></i></span>{{ ucfirst($resource) }}
<span class="btn-label"><i class="fa fa-fw fa-align-center"></i></span>
Header Order
</a>
<a class="btn btn-labeled btn-default text-black" href="{{ request()->url().'/order/footer' }}">
<span class="btn-label"><i class="fa fa-fw fa-align-center"></i></span>{{ ucfirst($resource) }}
<span class="btn-label"><i class="fa fa-fw fa-align-center"></i></span>
Footer Order
</a>
</div>

0 comments on commit ef81bba

Please sign in to comment.