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/dceprojects.corals.io/Corals/modules/ProjectPlan/Http/Requests/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/dceprojects.corals.io/Corals/modules/ProjectPlan/Http/Requests/ProjectRequest.php
<?php

namespace Corals\Modules\ProjectPlan\Http\Requests;

use Corals\Foundation\Http\Requests\BaseRequest;
use Corals\Modules\ProjectPlan\Models\Project;

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

        return $this->isAuthorized();
    }

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

        if ($this->isUpdate() || $this->isStore()) {
            $rules = array_merge($rules, [
                'name' => 'required',
                'owner_id' => 'required',
                'type' => 'nullable',
                'venue_id' => 'nullable',
                'customer_id' => 'nullable',
                'status' => 'required',
                'schedule' => 'array',
                'schedule.*.type' => 'nullable',
                'schedule.*.date' => 'nullable',
                'vendors' => 'array',
                'travels' => 'array',
                'position_crew' => 'array',
                'position_crew.*.*.rate' => 'numeric|gte:0',
                'position_crew.*.*.expected_regular_hours' => 'numeric|gte:0',
                'position_crew.*.*.expected_overtime_hours' => 'numeric|gte:0',
                'position_crew.*.*.total_cost' => 'numeric|gte:0',
                'vendors.*.*.vendor_id' => 'required',
                'travels.lodging.*.hotel_id' => 'required',
                'travels.airfare.*.airfare_code' => 'required',

            ]);

            foreach ($this->input('properties.required_vendors', []) as $vendorKey) {
                $rules["vendors.$vendorKey"] = 'required|array';
            }

            foreach ($this->input('properties.required_positions', []) as $positionKey) {
                $rules["position_crew.$positionKey"] = 'required|array';
            }
            foreach ($this->input('properties.required_travels', []) as $travelKey) {
                $rules["travels.$travelKey"] = 'required|array';
            }

        }

        if ($this->isStore()) {
            $rules = array_merge($rules, [
            ]);
        }

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

            $rules = array_merge($rules, [
            ]);
        }

        return $rules;
    }

    public function attributes()
    {
        if (!$this->isStore() && !$this->isUpdate()) {
            return [];
        }

        $attributes = [
            'schedule.*.date' => trans('ProjectPlan::attributes.schedule.date'),
            'schedule.*.start_time' => trans('ProjectPlan::attributes.schedule.first_call_time'),
            'schedule.*.end_time' => trans('ProjectPlan::attributes.schedule.expected_end_time'),
            'schedule.*.expected_ot' => trans('ProjectPlan::attributes.schedule.expected_ot'),
            'vendors.*.*.vendor_id' => trans('ProjectPlan::attributes.vendor.vendor'),
            'travels.lodging.*.hotel_id' => trans('ProjectPlan::attributes.hotel.hotel'),
            'travels.airfare.*.airfare_code' => trans('ProjectPlan::attributes.airfare.airfare'),
        ];

        foreach ($this->input('properties.required_vendors', []) as $vendorKey) {
            $attributes["vendors.$vendorKey"] = $vendorKey;
        }

        foreach ($this->input('properties.required_positions', []) as $positionKey) {
            $attributes["position_crew.$positionKey"] = $positionKey;
        }

        foreach ($this->input('properties.required_travels', []) as $travelKey) {
            $attributes["travels.$travelKey"] = $travelKey;
        }

        return $attributes;
    }

    protected function getValidatorInstance()
    {
        if ($this->isStore() || $this->isUpdate()) {
            $data = $this->all();
            if (empty($data['properties'])) {
                $data['properties'] = [];
                $this->getInputSource()->replace($data);
            }
        }

        return parent::getValidatorInstance();
    }
}

Spamworldpro Mini