This is the primary way that you can use to create a new review to the model through User Model.
You have to include the isReviewer trait into the User Model.
1namespace App\Models; 2 3use Illuminate\Foundation\Auth\User as Authenticatable; 4use Pharaonic\Laravel\Users\Traits\Actions\Review\isReviewer; 5 6class User extends Authenticatable 7{ 8 use isReviewer; 9 10 protected $fillable = ['name', 'email', 'password'];11}
This is how you can create a new review to the $course model through User model.
1// Model2// Rate3// Comment (OPTIONAL)4$user->review($course, 4.5, 'Review Text Here');5// Returns Boolean
This is how you can unreview the $course model through User model.
1$user->unreview($course);2// Returns Boolean
This is how you can check the $course model that has been reviewed by User model.
1if($user->reviewed($course)) {2 //3}
This is the secondary way that you can use to create a new review to the model.
You have to include the isReviewable trait into the Model.
1namespace App\Models; 2 3use Illuminate\Database\Eloquent\Model; 4use Pharaonic\Laravel\Users\Traits\Actions\Review\isReviewable; 5 6class Course extends Model 7{ 8 use isReviewable; 9 10 protected $fillable = ['title'];11}
This is how you can create a new review to the $course model.
1// Model2// Rate3// Comment (OPTIONAL)4$course->reviewBy($user, 4.5, 'Review Text Here');5// Returns Boolean
This is how you can unreview the $course model.
1$course->unreviewBy($user);2// Returns Boolean
This is how you can check the $course model that has been reviewed.
1if($course->reviewedBy($user)) {2 //3}
This is how you can get the average ratings of $course model.
1echo $course->rating;2// Returns Float