PHP code example of timgavin / laravel-block

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

    

timgavin / laravel-block example snippets


namespace App\Models;

use TimGavin\LaravelBlock\LaravelBlock;

class User extends Authenticatable
{
    use LaravelBlock;
}

auth()->user()->block($user);

auth()->user()->unblock($user);

@if (auth()->user()->isBlocking($user))
    You are blocking this user.
@endif

@if (auth()->user()->isBlockedBy($user))
    This user is blocking you.
@endif

auth()->user()->getBlocking();

auth()->user()->getBlockers();

auth()->user()->getBlockingIds();

auth()->user()->getBlockersIds();

auth()->user()->getBlockingAndBlockersIds()

// 1 day
auth()->user()->cacheBlocking();

// 1 hour
auth()->user()->cacheBlocking(3600);

// 1 month
auth()->user()->cacheBlocking(Carbon::addMonth());

auth()->user()->getBlockingCache();

auth()->user()->cacheBlockers();

auth()->user()->getBlockersCache();

auth()->user()->clearBlockingCache();

auth()->user()->clearBlockersCache();

php artisan migrate