PHP code example of mintbridge / eloquent-sentiment
1. Go to this page and download the library: Download mintbridge/eloquent-sentiment 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/ */
use Mintbridge\EloquentSentiment\Sentimentable;
use Mintbridge\EloquentSentiment\SentimentableInterface;
class Article extends Eloquent implements SentimentableInterface {
use Sentimentable;
...
}
$article = Article::find(1);
// add article as a favourite
Sentiment::add('like', $article);
// remove article from by a favourite
Sentiment::remove('like', $article);
// toggle article as being a favourite
Sentiment::toggle('like', $article);