Created
July 27, 2023 20:07
-
-
Save saaiful/6b13e9ceb8a7c6a051d50d5f1c53ad2c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// All Validation Blocks are For One Method | |
if ($request->quick) { | |
$request->validate([ | |
'quick' => 'required', | |
'pickup_id' => 'required', | |
]); | |
... | |
} | |
... | |
if ($request->mode == 'bulk') { | |
$request->validate([ | |
'pickup_id' => [ | |
'required', | |
Rule::exists('pickups', 'id')->where(function ($query) { | |
return $query->where('user_id', $this->user->id); | |
}), | |
], | |
'upload' => 'mimes:xls,xlsx|max:1024', | |
]); | |
} | |
... | |
if ($request->final == 'yes') { | |
$request->validate([ | |
'name.*' => 'required', | |
'mobile.*' => 'required|mobile', | |
'address.*' => 'required', | |
'cod.*' => 'nullable|cod|no_fraction', | |
'sale_price.*' => 'required', | |
'pickup_id.*' => 'required', | |
'package_id.*' => 'required', | |
'delivery_area.*' => 'required', | |
]); | |
} | |
... | |
/** | |
* Single Entry | |
* @var [type] | |
*/ | |
$request->validate([ | |
'pickup_id' => [ | |
'required', | |
Rule::exists('pickups', 'id')->where(function ($query) { | |
return $query->where('user_id', $this->user->id); | |
}), | |
], | |
'name' => 'required', | |
'mobile' => 'required|mobile', | |
'address' => 'required', | |
'package' => [ | |
'required', | |
Rule::exists('pricings', 'id')->where(function ($query) { | |
$uid = ($this->user->special_price > 0) ? $this->user->id : 0; | |
return $query->where('user_id', $uid); | |
}), | |
], | |
'delivery_area' => [ | |
'required', | |
Rule::exists('locations', 'id')->where(function ($query) { | |
return $query->where('status', 1); | |
}), | |
], | |
'sale_price' => 'required', | |
'cod' => 'nullable|cod|no_fraction', | |
]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment