mirror of
https://github.com/openclassify/openclassify.git
synced 2026-02-10 07:16:06 -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
|
* @type array|null
|
||||||
*/
|
*/
|
||||||
protected $plugins = [];
|
protected $plugins = [
|
||||||
|
CatsModulePlugin::class,
|
||||||
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The addon Artisan commands.
|
* The addon Artisan commands.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user