You can install this package using composer.
composer require marshmallow/reviews-kiyoh
To start using Kiyoh you need to publish the config and update the config accordingly. You need to add hash
, location_id
and feed_hash
to config/kiyoh.php
.
php artisan vendor:publish --provider="Marshmallow\Reviews\Kiyoh\ServiceProvider"
use Marshmallow\Reviews\Kiyoh\Facades\KiyohInvite;
use Marshmallow\Reviews\Kiyoh\Exceptions\KiyohException;
try {
KiyohInvite::email('[email protected]')
/**
* Optional
*/
->supplier('Marshmallow')
->firstName('Stef')
->lastName('van Esch')
->refCode('Order: #1001')
->city('Alphen aan den Rijn')
->delayIgnoreWeekend(3)
/**
* Always end with invite()
*/
->invite();
} catch (KiyohException $e) {
/**
* You should always try-catch this. Kiyoh can
* through an error if someone has already received
* an invitation. If this is thrown, you don't want
* you code to be killed!
*/
}
Using feed information is very easy. Use the Kiyoh
facade to access feed data. Available methods are listed below. Please note that by default the XML feed of Kiyoh will be cached using your default CACHE_DRIVER
. The feed will be cached for 1 hour. You can change this in config/kiyoh.php
. If for some reason the feed is unavailable an exeption will be thrown. If you are using these methods in blade you can prefix the methods with dontFail()
. If you use dontFail()
all methods will return 0
.
use Marshmallow\Reviews\Kiyoh\Facades\Kiyoh;
Kiyoh::feed()->average()
Kiyoh::dontFail()->feed()->average();
-
Kiyoh::feed()->average()
-
Kiyoh::feed()->count()
-
Kiyoh::feed()->average12months()
-
Kiyoh::feed()->count12months()
-
Kiyoh::feed()->recommendation()
-
Kiyoh::feed()->getAttribute('average')
If you wish to get all the reviews and store them in you own database or do whatever with it, you can get them with the methods below:
$reviews = Kiyoh::withoutCache()->feed();
foreach ($reviews as $review) {
// Do your own magic here
}
php artisan marshmallow:resource KiyohProduct Reviews\Kiyoh
Copyright (c) 2020 marshmallow.
The MIT License (MIT). Please see License File for more information.
php artisan test packages/marshmallow/reviews/kiyoh