HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/farmfun.komma.pro/app/Komma/Shop/ShipmentGroups/ShipmentGroupSection.php
<?php
/**
 * @author      Komma <info@komma.pro>
 * @copyright   (c) 2012-2016, Komma
 */

namespace App\Komma\Shop\ShipmentGroups;

//The new object oriented attributes
use App\Helpers\KommaHelpers;
use App\Komma\Globalization\RegionInfoInterface;
use App\Komma\Kms\Core\Attributes\Attribute;
use App\Komma\Kms\Core\Attributes\Models\SelectOption;
use App\Komma\Kms\Core\Attributes\Select;
use App\Komma\Kms\Core\Attributes\View;
use App\Komma\Kms\Core\Sections\Section;
use App\Komma\Kms\Core\Sections\Tabs\Collections\NoLanguageTabs;
use App\Komma\Pages\Models\Page;
use App\Komma\Routes\RouteService;
use App\Komma\Shop\Shipments\Shipment;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Collection;
use Illuminate\Support\MessageBag;

class ShipmentGroupSection extends Section
{
    public $showSave = 'all';

    public $showDelete = [1];

    public $showCreate = [1];

    /** @var ShipmentGroupService */
    protected $shipmentGroupService;

    /** @var RegionInfoInterface */
    private $regionInfo;

    /** @var RouteService */
    private $routeService;

    /**
     * ProductSection constructor.
     *
     * @param $slug
     */
//    function __construct(Kms $kms, PageRepository $repository)
    public function __construct($slug)
    {
        $sectionTabDirector = new NoLanguageTabs();
        parent::__construct($sectionTabDirector, $slug);
        $this->regionInfo = app(RegionInfoInterface::class);
        $this->routeService = app(RouteService::class);
        $this->routeService->setClassModelName(Page::class);
    }

    /**
     * Generates the attributes for this section. They all must extend the App\Komma\Kms\Core\Attributes\Attribute class
     * This is the place where you need to setup your sections appearance. Just make sure you build an array of attributes
     * and put each attribute in a AbstractSectionTabItem with a SectionTabGroups constant to link them to a tab.
     *
     * @see PageRepository::saveModel()
     * @param Model $currentModel
     * @return Collection A collection of SectionTabItems
     */
    protected function generateAttributes(Model $currentModel = null): Collection
    {
        /** @var ShipmentGroup $currentModel */
        //*****************************************************************************************\\
        //*** Define attribute validation sets                                                  ***\\
        //*****************************************************************************************\\

        //*****************************************************************************************\\
        //*** Determine and define status dropdown data                                         ***\\
        //*****************************************************************************************\\
        $statusOptions = [];
        foreach (ShipmentGroupStatus::getAsArray() as $shipmentGroupStatus) {
            $statusOptions[] = (new SelectOption())->setContent(__('shop/shipmentGroups.status.'.$shipmentGroupStatus))->setHtmlContent(__('shop/shipmentGroups.status.'.$shipmentGroupStatus))->setValue($shipmentGroupStatus);
        }

        //*****************************************************************************************\\
        //*** Generate the attributes                                                           ***\\
        //*****************************************************************************************\\
        $attributes = [];

        $attributes[] = (new Select())
            ->setItems($statusOptions)
            ->setLabelText(__('shop/shipmentGroups.status_name'))
            ->mapValueFrom(Attribute::ValueFromModel, 'status');

        $attributes[] = (new View('shop.partials.shipmentGroups.show'))->setViewData([
            'saveRoute' => $this->routeService->getSaveRoute($this->slug, $currentModel->id),
            'shipmentGroup' => $currentModel,
            'shipmentGroupShipments' => $currentModel->shipments()->with('order')->get(),
            'shipments' => Shipment::whereDoesntHave('shipmentGroup')->get(),
            'regionInfo' => $this->regionInfo,
        ]);

        //Return all attributes as a collection
        return collect($attributes);
    }

    /**
     * For the index controller action
     *
     * @return \Illuminate\Contracts\View\View
     */
    public function renderShipmentGroupIndex()
    {
        $saveRoute = $this->routeService->getSaveRoute($this->getSlug(), $this->getModelId());

        $successes = (\Session::has('successes')) ? \Session::get('successes') : new MessageBag();

        return view('kms/shop/shipmentGroups/index', [
            'siteSlug'                      => ! $this->siteService->getCurrentSite()->exists ? null : $this->siteService->getCurrentSite()->slug,
            'section'                      => $this,
            'saveRoute'                    => $saveRoute,
            'successes'                    => $successes,
            'maxUploadSize'                => KommaHelpers::fileUploadMaxSize(),
            'maxPostSize'                  => KommaHelpers::maxPostSize(),
            'preventNavigationTranslation' => json_encode(__('kms/prevent-navigation')),
        ]);
    }

    /**
     * Makes a full width view. The sidebar is not needed
     *
     * @return \Illuminate\Contracts\View\View
     */
    protected function makeView(): \Illuminate\Contracts\View\View
    {
        $saveRoute = $this->routeService->getSaveRoute($this->getSlug(), $this->getModelId());

        $successes = (\Session::has('successes')) ? \Session::get('successes') : new MessageBag();

        return view('kms/section.fullwidth', [
            'siteSlug'                     => ! $this->siteService->getCurrentSite()->exists ? null : $this->siteService->getCurrentSite()->slug,
            'section'                      => $this,
            'saveRoute'                    => $saveRoute,
            'successes'                    => $successes,
            'maxUploadSize'                => KommaHelpers::fileUploadMaxSize(),
            'maxPostSize'                  => KommaHelpers::maxPostSize(),
            'preventNavigationTranslation' => json_encode(__('kms/prevent-navigation')),
        ]);
    }

    /**
     * This method will stop the load entities of the kmsSiteSection
     *
     * @return array
     */
    public function loadEntities()
    {
        return [];
    }
}