This is the primary way that you can use to create a new comment to the model through User Model.
You have to include the isCommenter trait into the User Model.
1namespace App\Models; 2 3use Illuminate\Foundation\Auth\User as Authenticatable; 4use Pharaonic\Laravel\Users\Traits\Actions\Comment\isCommenter; 5 6class User extends Authenticatable 7{ 8 use isCommenter; 9 10 protected $fillable = ['name', 'email', 'password'];11}
This is how you can create a new comment to the $post model through User model.
1$user->comment($post);2// Returns Boolean
This is how you can check the $post model that has been commented by User model.
1if($user->commented($post)) {2 //3}
This is the secondary way that you can use to create a new comment to the model.
You have to include the isCommentable trait into the Model.
1namespace App\Models; 2 3use Illuminate\Database\Eloquent\Model; 4use Pharaonic\Laravel\Users\Traits\Actions\Comment\isCommentable; 5 6class Post extends Model 7{ 8 use isCommentable; 9 10 protected $fillable = ['body'];11}
This is how you can create a new comment to the $post model.
1$post->commentBy($user);2// Returns Boolean
This is how you can check the $post model that has been commented.
1if($article->commentedBy($user)) {2 //3}