Repository URL to install this package:
|
Version:
3.2.0 ▾
|
<?php
namespace Evsmash\Items\Exts;
use Evsmash\Core\Dec\Dec;
use Evsmash\Core\Helpers\Str;
use Evsmash\Core\Input\Route;
use Evsmash\Core\Simpy\Button;
use Evsmash\Core\Simpy\Element;
use Evsmash\Items\Item;
use Evsmash\Items\ItemsCategory;
class Bar {
// items
static public function items($elements) {
// basic
$bar = [
'create' => '/items/create',
'search' => true,
'params' => [
['Category', 'category', Bar::categories()],
['New', 'new', ['true' => 'Yes', 'false' => 'No']],
['Promoted', 'promoted', ['true' => 'Yes', 'false' => 'No']],
['Published', 'published', ['true' => 'Yes', 'false' => 'No']]
],
'summary' => $elements
];
// output
return $bar;
}
// item
static public function item($element) {
// basic
$bar = [
'shared' => [
'preview' => Button::preview(Route::map('evsmash/shop/items/show'), $element),
'items/edit' => Dec::a('/items/edit/'.$element->id, Dec::i('edit'), false)->class('btn btn-primary')->title(t('Edit')),
'translations/edit' => Button::translation('evsmash-shop-items', 'items', $element->id),
'metas/relation' => Button::metas('items', $element->id),
'photos/index' => Button::photos('items', $element->id),
'attachments/index' => Button::attachments('items', $element->id),
'actions/settings' => Button::settings('evsmash-shop-items-show', $element->id),
]
];
// title
$bar['title'] = $element->name;
// output
return $bar;
}
// SHARED
// shared items
static public function sharedItems($id) {
// element
$element = Element::check(new Item, $id);
// buttons
return Self::item($element);
}
// HELPERS
// categories
static public function categories() {
// get
$categories = ItemsCategory::where('depth', '>', 0)->orderBy('lft', 'asc')->get();
// output
$output = [];
foreach($categories as $row) {
$output[$row->id] = Str::multiple('-', ($row->depth - 1) * 2).' '.$row->name;
}
return $output;
}
}