File: D:/HostingSpaces/SBogers10/stafa.komma.pro/app/Komma/Shop/Bridges/SideBarShopMenuComposerBridge.php
<?php
namespace App\Komma\Shop\Bridges;
use Illuminate\Support\Facades\App;
class SideBarShopMenuComposerBridge
{
/**
* Returns an array of Shop Specific Menu bar items.
*
* @param string $currentSectionSlug
* @return array
*/
public static function get(string $currentSectionSlug):array
{
$routeName = \Route::current()->getName();
$items = [];
$items[] = [
'name' => ucfirst(__('shop/categories.categories')),
'url' => route('categories.index'),
'active' => ('categories' == $currentSectionSlug)
];
$items[] = [
'name' => ucfirst(__('shop/products.product_groups')),
'url' => route('productgroups.index'),
'active' => ('productgroups' == $currentSectionSlug)
];
$items[] = [
'name' => ucfirst(__('shop/products.product_composites')),
'url' => route('productcomposites.index'),
'active' => ('productcomposites' == $currentSectionSlug)
];
$items[] = [
'name' => ucfirst(__('shop/products.products')),
'url' => route('products.index'),
'active' => ('products' == $currentSectionSlug)
];
$items[] = [
'name' => ucfirst(__('shop/orders.orders')),
'subItems' => array_merge(
[
[
'name' => ucfirst(__('shop/orders.overview')),
'url' => route('orders.index'),
'active' => ('orders' == $currentSectionSlug) || $routeName == 'orders.index' || $routeName == 'orders.show'
]
],
self::getOrderStatusMenuItems($routeName)
),
'active' => ('orders' == $currentSectionSlug) || $routeName == 'orders.index' || $routeName == 'orders.show'
];
$items[] = [
'name' => ucfirst(__('shop/shipmentGroups.shipmentGroups')),
'url' => route('shipmentgroups.index'),
'active' => ('shipmentgroups' == $currentSectionSlug)
];
$items[] = [
'name' => ucfirst(__('shop/shipments.shipments')),
'url' => route('shipments.index'),
'active' => ('shipments' == $currentSectionSlug)
];
//TODO. The sidebar and section of this properties thing needs to be overhauled drastically to make it usefull
// $items[] = [
// 'name' => ucfirst(__('shop/properties.properties')),
// 'url' => route('properties.index'),
// 'active' => ('properties' == $currentSectionSlug)
// ];
//TODO. Make a sectio to manage discounts
// $items[] = [
// 'name' => ucfirst(__('shop/discounts.discounts')),
// 'url' => route('discounts.index', []),
// 'active' => ('discounts' == $currentSectionSlug)
// ];
return $items;
}
public static function getOrderStatusMenuItems(string $routeName)
{
$orderStatusSubItems = [];
// Order statuses are declared in language file
$orderStatuses = __('shop/orders.status');
if( ! is_array($orderStatuses)) throw new \RuntimeException('Order status translation files not found, run shop:translations to solve this problem. And first make sure the translations exist in the '.App::getLanguage()->iso_2.' language directory');
foreach($orderStatuses as $key => $translation) {
$orderStatusSubItems[] = [
'name' => $translation,
'url' => route('orders.search', [
'first_name'=> '',
'last_name'=> '',
'email'=> '',
'company'=> '',
'street'=> '',
'house_number'=> '',
'postal_code'=> '',
'status'=> $key,
'perPage'=> 20,
]),
'active' => ($routeName == 'orders.search' && \Route::current()->parameter('status') == $key)
];
}
return $orderStatusSubItems;
}
}