I have 2 tables named area_managers
and shopkeepers
. I want to validate email
from area_managers
while updating in a way so that it doesn't match with the email of shopkeepers
and area_managers
table. I tried the following way but it doesn't even allow the existed email of the respective user.
public function update(Request $request, AreaManager $areaManager)
{
$request->validate([
'email'=>'required|email|unique:shopkeepers,email|unique:area_managers,email,'.$areaManager->id,
]);
$areaManager-> email = $request->email;
$areaManager->update();
return redirect()->route('area_manager.edit',$areaManager->id);
}
CodePudding user response:
you should make a role with this command:
php artisan make:rule rolename
then in passes method set your query and then use in validator
CodePudding user response:
$this->validate($request(),[
'email' => 'required|email',
'password' => 'required'
]);