Trait for Laravel Eloquent models to allow easy implementation of a 'block' or 'ignore' feature.
racashmoney/laravel-blockable is a Laravel package for trait for laravel eloquent models to allow easy implementation of a 'block' or 'ignore' feature..
It currently has 4 GitHub stars and 25 downloads on Packagist (latest version 2.0.3).
Install it with composer require racashmoney/laravel-blockable.
Discover more Laravel packages by racashmoney
or browse all Laravel packages to compare alternatives.
Last updated
Trait for Laravel Eloquent models to allow easy implementation of a "block" or "ignore" feature.
composer require racashmoney/laravel-blockable "~2.0"
'providers' => [
\Racashmoney\Blockable\BlockableServiceProvider::class,
],
php artisan vendor:publish --provider="Racashmoney\Blockable\BlockableServiceProvider" --tag=migrations
php artisan migrate
class Article extends \Illuminate\Database\Eloquent\Model {
use \Racashmoney\Blockable\Blockable;
}
$article->block(); // block the article for current user
$article->block($myUserId); // pass in your own user id
$article->block(0); // just add blocks to the count, and don't track by user
$article->unblock(); // remove block from the article
$article->unblock($myUserId); // pass in your own user id
$article->unblock(0); // remove blocks from the count -- does not check for user
$article->blockCount; // get count of blocks
$article->blocks; // Iterable Illuminate\Database\Eloquent\Collection of existing blocks
$article->blocked(); // check if currently logged in user blocked the article
$article->blocked($myUserId);
Article::whereBlockedBy($myUserId) // find only articles where user blocked them
->with('blockCounter') // highly suggested to allow eager load
->get();