In first step we will install Socialite Package that provide fb api to connect with facebook. So, first open your terminal and run bellow command:
After install above package we should add providers and aliases in config file, Now open
config/app.php file and add service provider and alias.
In this step we need facebook app id and secret that way we can get information of other user. so if you don’t have facebook app account then you can create from here : https://developers.facebook.com/apps and after create account you can copy client id and secret.
Now you have to set app id, secret and call back url in config file so open config/services.php and .env file then set id and secret this way:
In this step first we have to create migration for add facebook_id in your user table. so let’s create new migration and bellow column this way:
Now add addNew() in User model, that method will check if facebook id already exists then it will return object and if not exists then create new user and return user object. so open user model and put bellow code:
In this step we need to create routes for facebook login, so you need to add following route on bellow file.
we need to add new controller and method of facebook auth that method will handle facebook callback url and etc, first put bellow code on your FacebookController.php file.
Ok, now at last we need to add blade view so first create new file facebook.blade.php file and put bellow code:
Ok, now you are ready to use open your browser and check here : URL + ‘/facebook’.
I hope it can help you…..