PHP code example of m1guelpf / laravel-apple-login
1. Go to this page and download the library: Download m1guelpf/laravel-apple-login library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use M1guelpf\LoginWithApple\LoginWithApple;
class AuthServiceProvider extends ServiceProvider
{
public function boot()
{
// ...
LoginWithApple::retrieveUserWith(function (\Laravel\Socialite\Two\User $appleUser) {
if ($user = User::where('apple_id', $appleUser->getId())->first() || ! $appleUser->getEmail()) {
return $user;
}
return User::create(['name' => $appleUser->getName(), 'email' => $appleUser->getEmail()]);
});
}
}
use Inertia\Inertia;
use M1guelpf\LoginWithApple\LoginWithApple;
class AuthServiceProvider extends ServiceProvider
{
public function boot()
{
// ...
LoginWithApple::redirectUsing(fn (string $url) => Inertia::location($url));
}
}
use M1guelpf\LoginWithApple\LoginWithApple;
class AuthServiceProvider extends ServiceProvider
{
public function boot()
{
// ...
LoginWithApple::ignoreMigrations();
LoginWithApple::ignoreRoutes();
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.