PHP code example of racashmoney / laravel-blockable
1. Go to this page and download the library: Download racashmoney/laravel-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/ */
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();