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

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/ledger.corals.io/Corals/modules/Ledger/Http/Requests/RecordRequest.php
<?php

namespace Corals\Modules\Ledger\Http\Requests;

use Corals\Foundation\Http\Requests\BaseRequest;
use Corals\Modules\Ledger\Models\Record;


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

        return $this->isAuthorized();
    }

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

        if ($this->isUpdate() || $this->isStore()) {
            $rules = array_merge($rules, [
                'account_id' => 'required',
                'record_date' => 'required',
                'type' => 'required',
                'payment_method' => 'required',
                'currency' => 'required',
                'amount' => 'required_without:items',
                'items.*.price' => 'required',
                'items.*.quantity' => 'required',
                'items.*.amount' => 'required',
                'items.*.notes' => 'nullable',
                'properties.*' => 'required_if:payment_method,cheque',
            ]);
        }

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

        if ($this->isUpdate()) {
            $rules = array_merge($rules, [

            ]);
        }

        return $rules;
    }

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

            if (empty($data['code'])) {
                $data['code'] = Record::getSeqCode('R');
            }

            $this->getInputSource()->replace($data);
        }
        return parent::getValidatorInstance();
    }

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

        return [
            'items.*.price' => '',
            'items.*.quantity' => '',
            'items.*.amount' => '',
            'items.*.notes' => '',
            'properties.paid_amount' => trans('Ledger::labels.cheque.cheque_amount'),
            'properties.cheque_number' => trans('Ledger::labels.cheque.cheque_number'),
            'properties.cheque_name' => trans('Ledger::labels.cheque.cheque_name'),
            'properties.cheque_date' => trans('Ledger::labels.cheque.cheque_date'),
            'properties.bank_name' => trans('Ledger::labels.cheque.bank_name'),
            'properties.bank_account_number' => trans('Ledger::labels.cheque.bank_account_number'),
        ];
    }
}

Spamworldpro Mini