PHP code example of mintbridge / eloquent-favourites
1. Go to this page and download the library: Download mintbridge/eloquent-favourites 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\EloquentFavourites\Favouritable;
use Mintbridge\EloquentFavourites\FavouritableInterface;
class Article extends Eloquent implements FavouritableInterface {
use Favouritable;
...
}
$article = Article::find(1);
// add article as a favourite
Favourites::add($article);
// remove article from by a favourite
Favourites::remove($article);
// toggle article as being a favourite
Favourites::toggle($article);