rinvex / laravel-testimonials
Rinvex Testimonials is a polymorphic Laravel package for managing testimonials. Customers can give you testimonials, and you can approve or disapprove each individually. Testimonials are good for showing the passion and love your service gets from customers, encouraging others to join the hype!
Installs: 2 552
Dependents: 1
Suggesters: 0
Security: 0
Stars: 15
Watchers: 3
Forks: 3
Open Issues: 0
Requires
- php: ^7.4.0 || ^8.0.0
- illuminate/console: ^8.0.0 || ^9.0.0
- illuminate/database: ^8.0.0 || ^9.0.0
- illuminate/support: ^8.0.0 || ^9.0.0
- rinvex/laravel-support: ^5.0.0
Requires (Dev)
- codedungeon/phpunit-result-printer: ^0.30.0
- illuminate/container: ^8.0.0 || ^9.0.0
- phpunit/phpunit: ^9.5.0
README
⚠️ This package is abandoned and no longer maintained. No replacement package was suggested. ⚠️
👉 If you are interested to step on as the main maintainer of this package, please reach out to me!
Rinvex Testimonials is a polymorphic Laravel package for managing testimonials. Customers can give you testimonials, and you can approve or disapprove each individually. Testimonials are good for showing the passion and love your service gets from customers, encouraging others to join the hype!
Installation
-
Install the package via composer:
composer require rinvex/laravel-testimonials
-
Publish resources (migrations and config files):
php artisan rinvex:publish:testimonials
-
Execute migrations via the following command:
php artisan rinvex:migrate:testimonials
-
Done!
Usage
Before going through the code samples, we need to clarify the concepts behind this package and how it works. Rinvex Testimonials assumes that every testimonial has two relationships, the is the entity giving the testimonial (called attestant), and second is the enity receiving it (called subject). These entities could be anything, each and every testimonial stores type
and id
(both form a polymorphic relationship) for subject and attestant. An entity can give testimonials, receive testimonials, or both. It's up to you to decide.
Add giving testimonials functionality to your model
To add support for a model to give testimonials simply use the \Rinvex\Testimonials\Traits\GivesTestimonials
trait:
namespace App\Models; use Illuminate\Database\Eloquent\Model; use Rinvex\Testimonials\Traits\GivesTestimonials; class User extends Model { use GivesTestimonials; }
Add receiving testimonials functionality to your model
To add support for a model to receive testimonials simply use the \Rinvex\Testimonials\Traits\TakesTestimonials
trait:
namespace App\Models; use Illuminate\Database\Eloquent\Model; use Rinvex\Testimonials\Traits\TakesTestimonials; class Company extends Model { use TakesTestimonials; }
Both traits could be used together for the same model without any issues.
Create a new testimonial
Creating a new testimonial is straight forward, and could be done in many ways, use whatever suits your context. Let's see how could we do that:
$user = \App\Models\User::find(1); $company = \App\Models\Company::find(1); $testimonial = app('rinvex.testimonials.testimonial'); $testimonialBody = 'I have been using this service as my main learning resource since it went live. I believe it has the best teaching material out there.'; // Create a new testimonial via subject model (attestant, body) $company->newTestimonial($user, $testimonialBody); // Create a new testimonial via attestant model (subject, body) $user->newTestimonial($company, $testimonialBody); // Create a new testimonial explicitly $testimonial->make(['body' => $testimonialBody]) ->subject()->associate($company) ->attestant()->associate($user) ->save();
Query testimonial models
You can get more details about a specific testimonial as follows:
$testimonial = app('rinvex.testimonials.testimonial')->find(1); $company = $testimonial->subject; // Get the owning company model $user = $testimonial->attestant; // Get the owning user model $testimonialsOfCompany = app('rinvex.testimonials.testimonial')->ofSubject($company)->get(); // Get testimonials of the given company $recommendationsOfUser = app('rinvex.testimonials.testimonial')->ofAttestant($user)->get(); // Get testimonials of the given user $company->testimonialsOf($user)->get(); // Get testimonials of the given user $user->recommendationsOf($company)->get(); // Get testimonials by the user for the given company $user->recommendations; // Get given testimonials collection $user->recommendations(); // Get given testimonials query builder $company->testimonials; // Get received testimonials collection $company->testimonials(); // Get received testimonials query builder
And not surprisingly, the \Rinvex\Testimonials\Models\Testimonial
model itself extends Eloquent so you can manage it fluently as you normally do.
Changelog
Refer to the Changelog for a full history of the project.
Support
The following support channels are available at your fingertips:
Contributing & Protocols
Thank you for considering contributing to this project! The contribution guide can be found in CONTRIBUTING.md.
Bug reports, feature requests, and pull requests are very welcome.
Security Vulnerabilities
If you discover a security vulnerability within this project, please send an e-mail to help@rinvex.com. All security vulnerabilities will be promptly testimonialed.
About Rinvex
Rinvex is a software solutions startup, specialized in integrated enterprise solutions for SMEs established in Alexandria, Egypt since June 2016. We believe that our drive The Value, The Reach, and The Impact is what differentiates us and unleash the endless possibilities of our philosophy through the power of software. We like to call it Innovation At The Speed Of Life. That’s how we do our share of advancing humanity.
License
This software is released under The MIT License (MIT).
(c) 2016-2021 Rinvex LLC, Some rights reserved.