This can cause if the foreach loop is finding null values and trying to insert null value but fails. so to avoid this what we can do, we can check if the request is null or there is value inside the request which came to the controller.
Example: Here we have used isset. you can use if else condition inside the foreach loop.
Example: Here we have used isset. you can use if else condition inside the foreach loop.
$roles= $request->role_name;
if(isset($roles)){
foreach($roles as $role)
{
...
}
}
Comments
Post a Comment