Laravel Watchable
Installation
Require this package, with Composer, in the root directory of your project.
$ composer require faustbrian/laravel-watchable
And then include the service provider within app/config/app.php
.
BrianFaust\Watchable\WatchableServiceProvider::class
At last you need to publish and run the migration.
php artisan vendor:publish --provider="BrianFaust\Watchable\WatchableServiceProvider" && php artisan migrate
Usage
Setup a Model
<?php
namespace App;
use BrianFaust\Watchable\HasWatchlistsTrait;
use BrianFaust\Watchable\Interfaces\HasWatchlists;
use Illuminate\Database\Eloquent\Model;
class User extends Model implements HasWatchlists
{
use HasWatchlistsTrait;
}
Create a new watchlist for the $user-model
$user->createWatchlist([
'title' => str_random(10),
'description' => str_random(10),
'type' => 'favorites',
]);
Add an item to a watchlist
$watchlist->addItem(Post::first());
Remove an item from a watchlist
$watchlist->removeItem(Post::first());
Security
If you discover a security vulnerability within this package, please send an e-mail to Brian Faust at [email protected]. All security vulnerabilities will be promptly addressed.