<?php

namespace Mehrab\Payment\Http\Requests;

use Hamcrest\Core\Set;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
use Mehrab\City\Repositories\CityRepo;
use Mehrab\Payment\Models\Settlement;
use Mehrab\RolePermission\Repositories\RoleRepo;
use Spatie\Permission\Models\Role;

class settlement_edit_request extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */

    public function rules()
    {
        return [
            'from_name' => ['required_if:status,'.Settlement::STATUS_SETTLED,'nullable','string'],
            'transaction_id' => ['required_if:status,'.Settlement::STATUS_SETTLED,'nullable','string'],
            'name' => ['required','string','min:2'],
            'cart' => ['required','numeric','digits:16'],
            'shaba' => ['required','string','regex:/^(?:IR)(?=.{24}$)[0-9]*$/'],
//            'amount' => ['required','numeric','min:0','max:'.(auth()->user()->amount+$this->amount)],
            'report' => ['nullable','string','max:1500'],
            'status' => ['required','string','in:'.Settlement::STATUS_CANCELED.','.Settlement::STATUS_REJECTED.','.Settlement::STATUS_SETTLED.','.Settlement::STATUS_PENDING],
        ];
    }
}
