PHP code example of agilesdesign / pseudo

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

    

agilesdesign / pseudo example snippets


'providers' => [
    Pseudo\Providers\PseudoServiceProvider::class,
];

Auth::check() // true if User false if Pseudo/Contracts/GuestContract 

Auth::user() // returns instance of Pseudo/Contracts/GuestContract instead of null if no user found

@can() // no longer automatically fails if not authenticated, allows Gate to be checked

'guards' => [
    // To use with web guard
    'web' => [
        'driver' => 'pseudo',
        'provider' => 'users',
    ],
    
    // To use with api guard
    'api' => [
        'driver' => 'pseudo-token',
        'provider' => 'users',
    ],
],

'providers' => [
    /*
     * Package Service Providers...
     */
    \Pseudo\Providers\PseudoServiceProvider::class,
],

public function register()
{
    $this->app->bind(GuestContract::class, Guest::class);
}

class GuestUser extends User implements GuestContract
{
    //You can override any attribute by using Eloquent Accessors
    public function getNameAttribute(){
        return 'Guest User';
    }
}

this->app->bind(\Pseudo\Contracts\GuestContract::class, \App\GuestUser::class);

Gate::define('create-article', function ($user, $article) {
    if($user instanceof Pseudo\Auth\Guest)
    {
      // logic for guest
    }
    else
    {
      // logic for authenticated
    }
});