New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

mintbridge/eloquent-sentiment

An eloquent package for adding sentiment to eloquent models.
256 1
Install
composer require mintbridge/eloquent-sentiment
Latest Version:0.0.1
PHP:>=5.4.0
Laravel:5
License:MIT
Last Updated:Feb 21, 2016
Links: GitHub  ·  Packagist
Maintainer: mintbridge

Eloquent Sentiment

Laravel 5 package for adding sentiment to eloquent models.

Installation

This package can be installed through Composer.

composer require mintbridge/eloquent-sentiment

Once installed add the service provider and facade to your app config

// config/app.php

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

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

You'll also need to publish and run the migration in order to create the database table.

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

The configuration will be written to config/eloquent-sentiment.php. The options have sensible defaults but you should change the user model to match the one used in your application.

Usage

This package will allow your users to add sentiment to models used in your application. To do so the models that you would like to be sentimentable must use the Sentimentable trait and implement SentimentableInterface.

use Mintbridge\EloquentSentiment\Sentimentable;
use Mintbridge\EloquentSentiment\SentimentableInterface;

class Article extends Eloquent implements SentimentableInterface {

    use Sentimentable;
    ...
}

Sentiment can be added to models by using the SentimentManager or more easily with the Sentiment facade:

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

Contributing

Please see CONTRIBUTING for details.

License

The MIT License (MIT). Please see License File for more information.

Related Packages

hopkins/aylien-model-traits

A trait that can be included on eloquent models to utilize the Aylien text analy...

12 0
sofa/hookable

Laravel Eloquent hooks system.

2,049,184 65
volosyuk/simple-eloquent

Adaptation of eloquent for retrieving its attributes

117,926 55
gzero/eloquent-tree

Eloquent Tree is a tree model for Laravel Eloquent ORM.

59,480 131
martinbean/laravel-sluggable-trait

A trait you can apply to Eloquent models to have slugs automatically generated o...

49,126 24

Version History

Version Released PHP Laravel License
0.0.1 >=5.4.0 5.* MIT