This is the primary way that you can use to create a new bookmark to the model through User Model.
You have to include the isBookmarker trait into the User Model.
1namespace App\Models; 2 3use Illuminate\Foundation\Auth\User as Authenticatable; 4use Pharaonic\Laravel\Users\Traits\Actions\Bookmark\isBookmarker; 5 6class User extends Authenticatable 7{ 8 use isBookmarker; 9 10 protected $fillable = ['name', 'email', 'password'];11}
This is how you can create a new bookmark to the $book model through User model.
1$user->bookmark($book); 2// Returns Boolean3 4// data [array] (OPTIONAL)5$user->bookmark($book, [6 'page' => 2,7 'line' => 88]);
This is how you can unbookmark the $book model through User model.
1$user->unbookmark($book);2// Returns Boolean
This is how you can check the $book model that has been bookmarked by User model.
1if($user->bookmarked($book)) {2 //3}
This is the secondary way that you can use to create a new bookmark to the model.
You have to include the isBookmarkable trait into the Model.
1namespace App\Models; 2 3use Illuminate\Database\Eloquent\Model; 4use Pharaonic\Laravel\Users\Traits\Actions\Bookmark\isBookmarkable; 5 6class Book extends Model 7{ 8 use isBookmarkable; 9 10 protected $fillable = ['title'];11}
This is how you can create a new bookmark to the $book model.
1$book->bookmarkBy($user); 2// Returns Boolean3 4// data [array] (OPTIONAL)5$book->bookmarkBy($user, [6 'page' => 2,7 'line' => 88]);
This is how you can unbookmark the $book model.
1$book->unbookmarkBy($user);2// Returns Boolean
This is how you can check the $book model that has been bookmarked.
1if($book->bookmarkedBy($user)) {2 //3}