Pharaonic
Loading...

# User Model

This is the primary way that you can use to create a new subscribe to the model through User Model.

# Inclusion

You have to include the isSubscriber trait into the User Model.

1namespace App\Models;
2 
3use Illuminate\Foundation\Auth\User as Authenticatable;
4use Pharaonic\Laravel\Users\Traits\Actions\Subscribe\isSubscriber;
5 
6class User extends Authenticatable
7{
8 use isSubscriber;
9 
10 protected $fillable = ['name', 'email', 'password'];
11}

# subscribe

This is how you can create a new subscribe to the $channel model through User model.

1$user->subscribe($channel);
2// Returns Boolean

# unsubscribe

This is how you can unsubscribe the $channel model through User model.

1$user->unsubscribe($channel);
2// Returns Boolean

# subscribed

This is how you can check the $channel model that has been subscribed by User model.

1if($user->subscribed($channel)) {
2 //
3}

# Subscribable Model

This is the secondary way that you can use to create a new subscribe to the model.

# Inclusion

You have to include the isSubscribable trait into the Model.

1namespace App\Models;
2 
3use Illuminate\Database\Eloquent\Model;
4use Pharaonic\Laravel\Users\Traits\Actions\Subscribe\isSubscribable;
5 
6class Channel extends Model
7{
8 use isSubscribable;
9 
10 protected $fillable = ['name'];
11}

# subscribeBy

This is how you can create a new subscribe to the $channel model.

1$channel->subscribeBy($user);
2// Returns Boolean

# unsubscribeBy

This is how you can unsubscribe the $channel model.

1$channel->unsubscribeBy($user);
2// Returns Boolean

# subscribedBy

This is how you can check the $channel model that has been subscribed.

1if($channel->subscribedBy($user)) {
2 //
3}

# Relationships

  • subscriptions
    • subscriber
    • subscribable