PHP code example of villabs / app-auth

1. Go to this page and download the library: Download villabs/app-auth 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/ */

    

villabs / app-auth example snippets


'guards' => [
    'app' => [
        'driver' => 'app',
        'provider' => 'app-provider',
    ],
  ...
]

'providers' => [
    'app-provider' => [
        'driver' => 'app',
        'model' => App\User::class,
    ],
    ...
 ]
 
 

/**
 * @param \Request $request
 * @return \Illuminate\Http\JsonResponse
 */
public function getLogin(Request $request)
{

  if (Auth::attempt($request->only(['email', 'password']))) {
      $user = Auth::user();
      $token = $user->token;

      return [
          "success" => true,
          "user" => $user,
          "token" => $token
      ];
  }
  
  return [
      "success" => false
  ];
}