PHP code example of probablyrational / laravel-user-blockable
1. Go to this page and download the library: Download probablyrational/laravel-user-blockable 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/ */
probablyrational / laravel-user-blockable example snippets
'providers' => [
ProbablyRational\LaravelBlockable\BlockableServiceProvider::class,
];
use ProbablyRational\LaravelBlockable\Traits\Blockable;
class User extends Model
{
use Blockable;
}
$user->block(1);
$user->block([1,2,3,4]);
$user->addBlockers(1);
$user->addBlockers([1,2,3,4]);
$user->unblock(1);
$user->unblock([1,2,3,4]);
// blocker users
$user->blockerUsers()->get(); // Get blocker user models.
$user->blockerRelationships()->get(); // Get blocker relationship models.
// blocked by users
$user->blockingUsers()->get();
$user->blockingRelationships()->get();
$user->isBlocking(1);
$user->isBlocking([1,2,3,4]);
$user->isBlockedBy(1);
$user->isBlockedBy([1,2,3,4]);
$user->isMutualBlock(1);
$user->isMutualBlock([1,2,3,4]);
$user->block([1,2,3]);
$user->blockerIds(); // [1,2,3]
$user->blockingIds();
$user->blockerUsers()->pluck('id')->all(); // [1,2,3]
$user->rejectNotBlocker([1,2,3,4,5]); // [1,2,3]
$user->block([1,2,3]);
$user->rejectNotBlocking([1,2,3,4,5]); // [1,2,3]