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

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/inventory.corals.io/Corals/modules/Inventory/Http/Requests/InventoryItemRequest.php
<?php

namespace Corals\Modules\Inventory\Http\Requests;

use Corals\Foundation\Http\Requests\BaseRequest;
use Corals\Modules\Inventory\Models\InventoryItem;
use Illuminate\Validation\Rule;


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

        return $this->isAuthorized();
    }

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


        if ($this->isUpdate() || $this->isStore()) {
            $rules = array_merge($rules, [
                'inventory_id' => [
                    'required',
                    'exists:inv_inventories,id',
                    Rule::unique('inv_inventory_has_items')->where('item_id', $this->item_id)
                ],
                'item_id' => [
                    'required',
                    'exists:inv_items,id',
                    Rule::unique('inv_inventory_has_items')->where('inventory_id', $this->inventory_id)
                ],
                'inventory_type' => 'required',
            ]);
        }

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

        if ($this->isUpdate()) {
            $id = InventoryItem::query()->where('id', $this->id)->value('id');


            $rules = array_merge($rules, [

                'inventory_id' => [
                    'required',
                    'exists:inv_inventories,id',
                    Rule::unique('inv_inventory_has_items')->where('item_id', $this->item_id)
                        ->whereNot('id', $id)
                ],

                'item_id' => [
                    'required',
                    'exists:inv_items,id',
                    Rule::unique('inv_inventory_has_items')->where('inventory_id', $this->inventory_id)
                        ->whereNot('id', $id)
                ],

            ]);
        }

        return $rules;
    }
}

Spamworldpro Mini