PHP code example of iget-master / token-auth
1. Go to this page and download the library: Download iget-master/token-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/ */
iget-master / token-auth example snippets
/**
* @param \Request $request
* @return \Illuminate\Http\JsonResponse
*/
public function getLogin(Request $request)
{
$success = false;
if (Auth::attempt($request->only(['email', 'password']))) {
$success = true;
$token = Auth::getToken();
$user_id = Auth::user()->id;
}
return response()->json(compact('success', 'token', 'user_id'));
}
use Illuminate\Http\Request;