Edit File: Edit.php
<?php namespace App\Http\Requests\Admin\Stores; use Illuminate\Foundation\Http\FormRequest; use App\Traits\ApiTrait; use App\Traits\GeneralTrait; class Edit extends FormRequest { use ApiTrait,GeneralTrait; /** * 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() { $val = ''; if($this->app_commission == 'percentage'){ $val = '|lt:100'; } return [ 'icon' => 'nullable|image', 'name_ar' => 'required|string|min:3|max:100', 'name_en' => 'required|string|min:3|max:100', 'bank_name' => 'nullable|string|min:3', 'bank_owner_name' => 'required|string', 'bank_number' => 'required|numeric|digits_between:10,24|unique:stores,bank_number,'.$this->id . ',id,deleted_at,NULL', 'iban_number' => 'nullable|min:10|unique:stores,iban_number,'. $this->id . ',id,deleted_at,NULL', 'address' => 'required', 'category' => 'required|exists:categories,slug', 'lat' => 'nullable', 'long' => 'nullable', 'has_contract' => 'required|in:1,0', 'avatar' => 'nullable|image', 'country_key' => 'required|nullable', 'phone' => 'required|nullable|min:9|unique:users,phone,'.$this->user_id . ',id,deleted_at,NULL', 'email' => 'required|nullable|email|unique:users,email,'.$this->user_id .',id,deleted_at,NULL', 'name' => 'required|nullable|string|min:3|max:100', 'password' => 'nullable|min:6', 'status' => 'nullable|in:active,block,pending', // 'commission_type' => 'required|nullable', // 'app_commission' => 'required|nullable|numeric|gt:0'.$val, ]; } public function messages(){ return [ 'name.required_if' => trans('auth.nam_req_if'), 'phone.required_if' => trans('auth.phn_req_if'), 'email.required_if' => trans('auth.ema_req_if'), ]; } protected function prepareForValidation() { $number = $this->convert2english($this->phone); $phone = $this->phoneValidate($number); $this->merge([ 'phone' => $phone , ]); } }
Back to File Manager