Pharaonic
Loading...

# User Model

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

# Inclusion

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

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

# follow

This is how you can create a new follow to the $page model through User model.

1$user->follow($page);
2// Returns Boolean

# unfollow

This is how you can unfollow the $page model through User model.

1$user->unfollow($page);
2// Returns Boolean

# followed

This is how you can check the $page model that has been followed by User model.

1if($user->followed($page)) {
2 //
3}

# Followable Model

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

# Inclusion

You have to include the isFollowable trait into the Model.

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

# followBy

This is how you can create a new follow to the $page model.

1$page->followBy($user);
2// Returns Boolean

# unfollowBy

This is how you can unfollow the $page model.

1$page->unfollowBy($user);
2// Returns Boolean

# followedBy

This is how you can check the $page model that has been followed.

1if($page->followedBy($user)) {
2 //
3}

# Relationships

  • follows
    • follower
    • followable