This commit is contained in:
vedatakd 2019-10-11 16:20:38 +03:00
parent 4c66214196
commit 17509e4148
3 changed files with 64 additions and 3 deletions

View File

@ -7,12 +7,24 @@
{% if table.options.sortable %}
{{ asset_add("scripts.js", "streams::js/table/sortable.js") }}
{% endif %}
{% if app.request.get('cat') != null %}
{% set parent = category_detail(app.request.get('cat')) %}
{% if parent.parent_category is null %}
{% set parent_url = url('admin/cats') %}
{% else %}
{% set parent_url = url('admin/cats?cat='~parent.parent_category_id) %}
{% endif %}
<div class="container-fluid">
<div id="buttons">
<a class="btn btn-md btn-warning " href="{{ parent_url }}">
<i class="fa fa-arrow-left"></i> Go To Parent ../<b><u>{{ parent.name }}</u></b>
</a>
</div>
</div>
{% endif %}
<div class="container-fluid">
{{ view("streams::table/partials/filters", {'table': table}) }}
{{ view("streams::table/partials/views", {'table': table}) }}
{{ view(table.options.heading ?: "streams::table/partials/heading", {'table': table}) }}
{% if not table.rows.empty() %}
{% block card %}

View File

@ -0,0 +1,38 @@
<?php namespace Visiosoft\CatsModule\Category\Command;
use Visiosoft\CatsModule\Category\Contract\CategoryRepositoryInterface;
class GetCategoryDetail
{
/**
* @var $id
*/
protected $id;
/**
* GetProduct constructor.
* @param $id
*/
public function __construct($id)
{
$this->id = $id;
}
/**
* @param CategoryRepositoryInterface $groups
* @return |null
*/
public function handle(CategoryRepositoryInterface $groups)
{
if ($this->id) {
$category = $groups->find($this->id);
if (!is_null($category))
return $category;
else
return null;
}
return null;
}
}

View File

@ -2,6 +2,7 @@
use Anomaly\Streams\Platform\Addon\Plugin\Plugin;
use Visiosoft\CatsModule\Category\Command\GetCategoryName;
use Visiosoft\CatsModule\Category\Command\GetCategoryDetail;
class CatsModulePlugin extends Plugin
{
@ -20,6 +21,16 @@ class CatsModulePlugin extends Plugin
return null;
}
return $ad;
}
),new \Twig_SimpleFunction(
'category_detail',
function ($id) {
if (!$ad = $this->dispatch(new GetCategoryDetail($id))) {
return null;
}
return $ad;
}
)