PHP code example of gorankrgovic / laravel-subscribeable

1. Go to this page and download the library: Download gorankrgovic/laravel-subscribeable 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/ */

    

gorankrgovic / laravel-subscribeable example snippets


use Gox\Contracts\Subscribe\Subscriber\Models\Subscriber as SubscriberContract;
use Gox\Laravel\Subscribe\Subscriber\Models\Traits\Subscriber;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable implements SubscriberContract
{
    use Subscriber;
}

use Gox\Contracts\Subscribe\Subscribeable\Models\Subscribeable as SubscribeableContract;
use Gox\Laravel\Subscribe\Subscribeable\Models\Traits\Subscribeable;
use Illuminate\Database\Eloquent\Model;

class Article extends Model implements SubscribeableContract
{
    use Subscribeable;
}

$user->subscribe($article);

$article->subscrubeBy(); // current user
$article->subscribeBy($user->id);

$user->unsubscribe($article);

$article->unsubscribeBy(); // current user
$article->unsubscribeBy($user->id);

$article->subcribesCount;

$article->subscribesCounter;

$article->subscribes();

$article->subscribes;

$user->hasSubscribed($article);

$article->subscribed; // current user
$article->isSubscribedBy(); // current user
$article->isSubscribedBy($user->id);

$article->collectSubscribers();

$article->removeSubscribes();

Article::whereSubscribedBy($user->id)
    ->with('subscribesCounter') // Allow eager load (optional)
    ->get();

$sortedArticles = Article::orderBySubscribesCount()->get();
$sortedArticles = Article::orderBySubscribesCount('asc')->get();

$this->app->bind(
    \Gox\Contracts\Subscribe\Subscribe\Models\Subscribe::class,
    \App\Models\CustomSubscribe::class
);

$model = app(\Gox\Contracts\Subscribe\Subscribe\Models\Subscribe::class);
sh
$ php artisan migrate