PHP code example of zendraxl / laravel-request-null-user
1. Go to this page and download the library: Download zendraxl/laravel-request-null-user 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/ */
zendraxl / laravel-request-null-user example snippets
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index(\Illuminate\Http\Request $request)
{
$owner = $request->owner();
// ...
}
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$owner = \Illuminate\Support\Facades\Request::owner();
// ...
}
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$owner = request()->owner();
// ...
}
public $email = '[email protected]';
public $name = 'Guest';
public $type = 'guest';
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Zendraxl\LaravelRequestNullUser\Owner;
class AppServiceProvider extends ServiceProvider
{
public function boot(): void
{
Owner::macro('isAdmin', function () {
return $this->type === 'admin';
});
}
}