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/ */

    

mintbridge / eloquent-sentiment example snippets


// config/app.php

'providers' => [
    '...',
    'Mintbridge\EloquentSentiment\SentimentServiceProvider',
];

'aliases' => [
    '...',
    'Sentiment' => 'Mintbridge\EloquentSentiment\SentimentFacade',
];

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);

php artisan vendor:publish --provider="Mintbridge\EloquentSentiment\SentimentServiceProvider" --tag="config"
php artisan vendor:publish --provider="Mintbridge\EloquentSentiment\SentimentServiceProvider" --tag="migrations"
php artisan migrate
config/eloquent-sentiment.php