PHP code example of incraigulous / request-hooks
1. Go to this page and download the library: Download incraigulous/request-hooks 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/ */
incraigulous / request-hooks example snippets
namespace App\RequestHooks;
use Illuminate\Http\Request;
use App\User;
use Incraigulous\RequestHooks\Contracts\RequestHook;
class Login implements RequestHook
{
/**
* @var Request
*/
private $request;
function __construct(Request $request)
{
$this->request = $request;
}
/**
* Should the hook fire?
* @return bool
*/
public function shouldHandle()
{
if (!$this->request->test_login) return false;
if (auth()->check()) return false;
return true;
}
/**
* Do whatever action the hook does
*/
public function handle()
{
$user = user::first();
auth()->login($user);
}
}