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/kooken.komma.pro/vendor/komma/kms/src/ActionLog/ActionLogSection.php
<?php
namespace Komma\KMS\ActionLog;

//The new object oriented attributes
use Komma\KMS\Core\Attributes\Attribute;
use Komma\KMS\Core\Attributes\DatePicker;
use Komma\KMS\Core\Attributes\Models\SelectOption;
use Komma\KMS\Core\Attributes\Select;
use Komma\KMS\Core\Sections\Section;
use Komma\KMS\Core\Attributes\Title;
use Komma\KMS\Core\Sections\Tabs\Collections\NoLanguageTabs;
use Komma\KMS\Providers\SetupServiceProvider;
use Komma\KMS\Users\Kms\KmsUserService;
use Komma\KMS\Users\Models\KmsUserRole;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Collection;

final class ActionLogSection extends Section
{
    protected $title = "Action log";
    protected $subtitle = "Who did what";
    protected $slug = "actionlog";
    protected $hasRoutes = false;
    protected $packagePrefix = SetupServiceProvider::PACKAGE_NAMESPACE.'::';

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

    /**
     * @var ActionLogModelService $sectionService
     */
    protected $sectionService;

    /** @var KmsUserService $userService */
    private $userService;

    /**
     * PageSection constructor.
     * @param string $slug
     */
//    function __construct(Kms $kms, PageRepository $repository)
    function __construct(string $slug)
    {
        $this->title = ucfirst(__('KMS::kms/actionlog.section.title'));
        $this->submitButtonLabel = __('KMS::kms/actionlog.retrieve');

        $this->userService = app(KmsUserService::class);

        $sectionTabDirector = new NoLanguageTabs();
        parent::__construct($sectionTabDirector, $slug);
    }

    /**
     * Generates the attributes for this section. They all must extend the App\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
    {
//        \Log::info("PageSection::Generating attributes");

        //*****************************************************************************************\\
        //*** Define attribute validation sets                                                  ***\\
        //*****************************************************************************************\\


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

        //Build the general attributes and put them in the attributes array
        $attributes[] = (new Title(__('KMS::kms/actionlog.section.title')))
                        ->setMinimumUserRole(KmsUserRole::Admin);

        $attributes[] = (new DatePicker(__('KMS::kms/actionlog.from')))
                        ->setMinimumUserRole(KmsUserRole::Admin)
                        ->mapValueFrom(Attribute::ValueFromItself, 'from');


        $attributes[] = (new DatePicker(__('KMS::kms/actionlog.trough')))
                        ->setMinimumUserRole(KmsUserRole::Admin)
                        ->mapValueFrom(Attribute::ValueFromItself, 'trough');

        $userSelectOptionModels = $this->userService->getOptionsForSelect();
        $userSelectOptionModels->prepend(
            (new SelectOption())
                ->setContent(__('KMS::kms/actionlog.all_users'))
                ->setHtmlContent(__('KMS::kms/actionlog.all_users'))
                ->setValue(0)
        );

        $attributes[] = (new Select())
            ->setItems($userSelectOptionModels->toArray())
            ->setLabelText(__('KMS::kms/actionlog.user_filter'))
            ->setMinimumUserRole(KmsUserRole::Admin)
            ->mapValueFrom(Attribute::ValueFromItself, 'user_filter');


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