1. Go to this page and download the library: Download zing/laravel-subscribe 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/ */
zing / laravel-subscribe example snippets
use Illuminate\Database\Eloquent\Model;
use LaravelInteraction\Subscribe\Concerns\Subscriber;
class User extends Model
{
use Subscriber;
}
use Illuminate\Database\Eloquent\Model;
use LaravelInteraction\Subscribe\Concerns\Subscribable;
class Channel extends Model
{
use Subscribable;
}
use LaravelInteraction\Subscribe\Tests\Models\Channel;
/** @var \LaravelInteraction\Subscribe\Tests\Models\User $user */
/** @var \LaravelInteraction\Subscribe\Tests\Models\Channel $channel */
// Subscribe to Subscribable
$user->subscribe($channel);
$user->unsubscribe($channel);
$user->toggleSubscribe($channel);
// Compare Subscribable
$user->hasSubscribed($channel);
$user->hasNotSubscribed($channel);
// Get subscribed info
$user->subscriberSubscriptions()->count();
// with type
$user->subscriberSubscriptions()->withType(Channel::class)->count();
// get subscribed channels
Channel::query()->whereSubscribedBy($user)->get();
// get subscribed channels doesnt subscribed
Channel::query()->whereNotSubscribedBy($user)->get();