| Server IP : 34.87.99.72 / Your IP : 216.73.217.31 Web Server : Apache/2.4.46 (Unix) OpenSSL/1.1.1n System : Linux zlock-bitnami-lamp-prod-v2-vm 4.19.0-16-cloud-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64 User : bitnami ( 1000) PHP Version : 7.4.18 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /opt/bitnami/apache/htdocs/app/app/Http/Requests/BoxDeliveries/ |
Upload File : |
<?php
namespace App\Http\Requests\BoxDeliveries;
use Illuminate\Foundation\Http\FormRequest;
use App\Rules\PhoneNumber;
use App\Models\UserBoxDelivery;
use Illuminate\Validation\Rule;
class BookingRequest extends FormRequest
{
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'locker_id' => 'required|integer',
'box_size_id' => 'required|integer',
'delivery_partner_id' => 'required|integer|exists:couriers,id',
'parcel_info' => 'required|string|max:50',
'parcel_type' => ['required', Rule::in(UserBoxDelivery::PARCEL, UserBoxDelivery::DOCUMENT)],
'parcel_length' => 'nullable|regex:/^\d*(\.\d{1,2})?$/',
'parcel_width' => 'nullable|regex:/^\d*(\.\d{1,2})?$/',
'parcel_height' => 'nullable|regex:/^\d*(\.\d{1,2})?$/',
'parcel_weight' => 'required|numeric|regex:/^\d*(\.\d{1,2})?$/|min:'.UserBoxDelivery::MIN_WEIGHT.'|max:'.UserBoxDelivery::WEIGHT_LIMIT,
'dropper_name' => 'required|string',
'dropper_num' => ['required', 'starts_with:+60', 'phone:AUTO,MY'],
'receiver_name' => 'required|string',
'receiver_email' => 'sometimes|email',
'receiver_num' => ['required', 'starts_with:+60', 'phone:AUTO,MY'],
'receiver_house_num' => 'required|string|max:25',
'receiver_address' => 'required|string|max:90',
'receiver_postcode' => 'required|string|exists:postcodes,name',
'receiver_city' => 'required|string',
'receiver_state' => 'required|string|exists:states,name',
'remarks' => 'nullable|string|max:90',
'credit_amount' => ['required','numeric','regex:/^-?\d*(\.\d{1,2})?$/','min:0'],
];
}
/**
* Custom message for validation
*
* @return array
*/
public function messages()
{
return [
'dropper_num.phone' => 'Invalid phone number.',
'receiver_num.phone' => 'Invalid phone number.',
'dropper_num.starts_with' => 'Phone number must be Malaysia-based and starts with +60',
'receiver_num.starts_with' => 'Phone number must be Malaysia-based and starts with +60',
'parcel_length.required_if' => 'Please enter the parcel length if parcel type is selected',
'parcel_width.required_if' => 'Please enter the parcel width if parcel type is selected',
'parcel_height.required_if' => 'Please enter the parcel height if parcel type is selected',
];
}
}