Handle exception in laravel
I have written code for creating roles in laravel i am using spatie package when i try to create new role then it gives exception like
Spatie Permission Exceptions RoleDoesNotExist
I know its generating because role does not exists, i dont know how to handle exception in laravel.
also is there any way i can first check role exists or not and then add the role?
following is my code
public function create()
{
//print_r($_POST);
$role_name=$_POST['name'];
$create_product=NULL;
$edit_product=NULL;
$view_product=NULL;
if(isset($_POST['create_products']))
{
$create_product=$_POST['create_products'];
}
if(isset($_POST['view_products']))
{
$view_product=$_POST['view_products'];
}
if(isset($_POST['edit_products']))
{
$edit_product=$_POST['edit_products'];
}
echo $create_product; echo $view_product; echo $edit_product;
dd(Role::findByName($role_name));
from Laravel Questions and Answers https://laravelquestions.com/php/handle-exception-in-laravel/
via Lzo Media
Lance Developer London: Handle Exception In Laravel - Development >>>>> Download Now
ReplyDelete>>>>> Download Full
Lance Developer London: Handle Exception In Laravel - Development >>>>> Download LINK
>>>>> Download Now
Lance Developer London: Handle Exception In Laravel - Development >>>>> Download Full
>>>>> Download LINK Fm