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/lmbm.komma.pro/app/KommaApp/Kms/Transfer/TransferSection.php
<?php
namespace App\KommaApp\Kms\Transfer;

//The new object oriented attributes
use App\Helpers\KommaHelpers;
use App\KommaApp\Kms\Core\Attributes\Attribute;
use App\KommaApp\Kms\Core\Attributes\File;
use App\KommaApp\Kms\Core\Sections\NoLanguageTabsDirector;
use App\KommaApp\Kms\Core\Sections\Section;
use App\KommaApp\Routes\RouteService;

use App\KommaApp\Kms\Core\Attributes\Title;
use App\KommaApp\Kms\Core\Sections\SectionTabGroups;
use App\KommaApp\Kms\Core\Sections\SectionTabItem;
use App\KommaApp\Kms\Core\Sections\SectionTabsBuilder;
use App\KommaApp\Kms\Core\ValidationSet;
use Illuminate\Contracts\View\View;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Support\MessageBag;

class TransferSection extends Section
{
    protected $title = "Importeren";
    protected $subTitle = "All pages";
    protected $slug = "transfer";
    protected $hasRoutes = true;

    public $showSave = 'all';
    public $showDelete = [];
    public $showCreate = [];

    /**
     * PageSection constructor.
     * @param TransferService $sectionService
     * @param RouteService $routeService
     */
//    function __construct(Kms $kms, PageRepository $repository)
    function __construct(TransferService $sectionService, RouteService $routeService)
    {
        $this->title = ucfirst(__('kms/transfer.transfer'));
        $this->subTitle = __('kms/transfer.transfersubtitle');

        $sectionTabDirector = new NoLanguageTabsDirector(new SectionTabsBuilder());
        parent::__construct($sectionService, $routeService, $sectionTabDirector);
        $this->submitButtonLabel = __('kms/transfer.transfer');
    }

    /**
     * Generates the attributes for this section. They all must extend the App\KommaApp\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()
     * @return Collection A collection of SectionTabItems
     */
    protected function generateAttributes(): Collection
    {
//        \Log::info("PageSection::Generating attributes");

        //*****************************************************************************************\\
        //*** Define attribute validation sets                                                  ***\\
        //*****************************************************************************************\\
        $codeNameValidationSet = (new ValidationSet())
            ->setRules('required')
            ->setMessages(['required' => __('validation.required')]);

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

        //Build the general attributes and put them in the attributes array
        $attributes[] = (new Title(__('kms/transfer.transfer')));

        $attributes[] = (new File(__('kms/transfer.import')))->setAccept('text/csv')->mapValueFrom(Attribute::ValueFromItself, 'file');

        //Build an array with attributes for each current site language
        $languageIndexedAttributes = $this->createAttributesFromExistingAttributeForCurrentSiteLanguages([
        ]);

        //****************************************************************************************************************************************\\
        //*** Put the all attributes in a SectionTabItem so we can track for which tab they are. And then put SectionTabItems in a Collection  ***\\
        //****************************************************************************************************************************************\\
        $tabItems = new Collection();
        foreach($attributes as $attribute) $tabItems->push(new SectionTabItem($attribute, SectionTabGroups::General));
        foreach($languageIndexedAttributes as $attribute) $tabItems->push(new SectionTabItem($attribute, SectionTabGroups::Languages));

        return $tabItems;
    }

    /**K
     * Returns a rendered view
     *
     * @return \Illuminate\Contracts\View\View
     */
    public function render()
    {
        return parent::render(); // TODO: Change the autogenerated stub
    }


    /**
     * Makes the view and returns it
     *
     * @return View
     */
    protected function makeView(): View
    {
        $successes = (\Session::has('successes')) ? \Session::get('successes') : new MessageBag();

        return \View::make('kms/section.transfer', [
            'kms' => $this->kms,
            'section' => $this,
            'importExportDataRoute' => [
                'route' => route('transfer.transfer'),
                'method' => 'POST'
            ],
            'importDocumentsRoute' => [
                'route' => route('transfer.import_documents'),
                'method' => 'POST'
            ],
            'successes' => $successes,
            'maxUploadSize' => KommaHelpers::fileUploadMaxSize()
        ]);
    }

    public function getModelTitle()
    {
        return __('kms/transfer.transfer');
    }
}