mirror of
https://github.com/openclassify/openclassify.git
synced 2026-01-11 18:01:10 -06:00
Create Category Twig Function && Remove old table
This commit is contained in:
parent
c7d3a742a7
commit
9dbca4efb9
@ -1,42 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Anomaly\Streams\Platform\Database\Migration\Migration;
|
||||
|
||||
class VisiosoftModuleAdvsCreateCustomFieldsStream extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* The stream definition.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $stream = [
|
||||
'slug' => 'custom_fields',
|
||||
'title_column' => 'name',
|
||||
'translatable' => true,
|
||||
'trashable' => false,
|
||||
'searchable' => false,
|
||||
'sortable' => false,
|
||||
];
|
||||
|
||||
/**
|
||||
* The stream assignments.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $assignments = [
|
||||
'parent_category',
|
||||
'type',
|
||||
'name' => [
|
||||
'translatable' => true,
|
||||
'required' => true,
|
||||
],
|
||||
'slug' => [
|
||||
'unique' => true,
|
||||
'required' => true,
|
||||
],
|
||||
'custom_field_select_options',
|
||||
'description',
|
||||
];
|
||||
|
||||
}
|
||||
@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Anomaly\Streams\Platform\Database\Migration\Migration;
|
||||
|
||||
class VisiosoftModuleAdvsCreateCustomFieldAdvsStream extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* The stream definition.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $stream = [
|
||||
'slug' => 'custom_field_advs',
|
||||
'translatable' => true,
|
||||
'trashable' => false,
|
||||
'searchable' => false,
|
||||
'sortable' => false,
|
||||
];
|
||||
|
||||
/**
|
||||
* The stream assignments.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $assignments = [
|
||||
'parent_adv',
|
||||
'custom_field_category',
|
||||
'custom_field_value',
|
||||
'custom_field_type'
|
||||
];
|
||||
|
||||
}
|
||||
@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Anomaly\Streams\Platform\Database\Migration\Migration;
|
||||
|
||||
class VisiosoftModuleAdvsCreateCfValuesStream extends Migration
|
||||
{
|
||||
|
||||
/**
|
||||
* The stream definition.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $stream = [
|
||||
'slug' => 'cf_values',
|
||||
'title_column' => 'value',
|
||||
'translatable' => true,
|
||||
'versionable' => false,
|
||||
'trashable' => false,
|
||||
'searchable' => false,
|
||||
'sortable' => false,
|
||||
];
|
||||
|
||||
/**
|
||||
* The stream assignments.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $assignments = [
|
||||
'custom_field',
|
||||
'value' => [
|
||||
'translatable' => true
|
||||
]
|
||||
];
|
||||
}
|
||||
@ -0,0 +1,38 @@
|
||||
<?php namespace Visiosoft\CatsModule\Category\Command;
|
||||
|
||||
use Visiosoft\CatsModule\Category\Contract\CategoryRepositoryInterface;
|
||||
|
||||
class GetCategoryName
|
||||
{
|
||||
|
||||
/**
|
||||
* @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->name;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
<?php namespace Visiosoft\CatsModule;
|
||||
|
||||
use Anomaly\Streams\Platform\Addon\Plugin\Plugin;
|
||||
use Visiosoft\CatsModule\Category\Command\GetCategoryName;
|
||||
|
||||
class CatsModulePlugin extends Plugin
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getFunctions()
|
||||
{
|
||||
return [
|
||||
new \Twig_SimpleFunction(
|
||||
'category_name',
|
||||
function ($id) {
|
||||
|
||||
if (!$ad = $this->dispatch(new GetCategoryName($id))) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $ad;
|
||||
}
|
||||
)
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -19,7 +19,9 @@ class CatsModuleServiceProvider extends AddonServiceProvider
|
||||
*
|
||||
* @type array|null
|
||||
*/
|
||||
protected $plugins = [];
|
||||
protected $plugins = [
|
||||
CatsModulePlugin::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* The addon Artisan commands.
|
||||
@ -48,11 +50,11 @@ class CatsModuleServiceProvider extends AddonServiceProvider
|
||||
* @type array|null
|
||||
*/
|
||||
protected $routes = [
|
||||
'admin/cats/placeholderforsearch' => 'Visiosoft\CatsModule\Http\Controller\Admin\PlaceholderforsearchController@index',
|
||||
'admin/cats/placeholderforsearch/create' => 'Visiosoft\CatsModule\Http\Controller\Admin\PlaceholderforsearchController@create',
|
||||
'admin/cats/placeholderforsearch' => 'Visiosoft\CatsModule\Http\Controller\Admin\PlaceholderforsearchController@index',
|
||||
'admin/cats/placeholderforsearch/create' => 'Visiosoft\CatsModule\Http\Controller\Admin\PlaceholderforsearchController@create',
|
||||
'admin/cats/placeholderforsearch/edit/{id}' => 'Visiosoft\CatsModule\Http\Controller\Admin\PlaceholderforsearchController@edit',
|
||||
'admin/cats' => 'Visiosoft\CatsModule\Http\Controller\Admin\CategoryController@index',
|
||||
'admin/cats/create' => 'Visiosoft\CatsModule\Http\Controller\Admin\CategoryController@create',
|
||||
'admin/cats' => 'Visiosoft\CatsModule\Http\Controller\Admin\CategoryController@index',
|
||||
'admin/cats/create' => 'Visiosoft\CatsModule\Http\Controller\Admin\CategoryController@create',
|
||||
'admin/cats/edit/{id}' => 'Visiosoft\CatsModule\Http\Controller\Admin\CategoryController@edit',
|
||||
'admin/cats/category/delete/{id}' => 'Visiosoft\CatsModule\Http\Controller\Admin\CategoryController@delete',
|
||||
];
|
||||
|
||||
Loading…
Reference in New Issue
Block a user