PHP code example of wikigods / jraty

1. Go to this page and download the library: Download wikigods/jraty library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

wikigods / jraty example snippets


echo Jraty::js()

echo Jraty::js_init($params=[]);

Jraty::js_init([
    'score' => 'function() { return $(this).attr(\'data-score\'); }',
    'number' => 5,
    'click' => 'function(score, evt) {
                $.post(\'save/item_rating\',{
                    item_id: $(\'[data-item]\').attr(\'data-item\'),
                    score: score
                });
              }',
    'path' => '\'vendor/wikigods/jraty/img\''
]);

echo Jraty::html($item_id, $item_name='', $item_photo='', $seo=true);

Jraty::delete($id)

$data = [
        'item_id'    => Request::get('item_id'),
        'score'      => Request::get('score'),
        'added_on'   => DB::raw('NOW()'),
        'ip_address' => Request::getClientIp()
		];
Jraty::add($data);

$rating = Jraty::get($item_id);
echo $rating->avg; // avarage score
echo $rating->votes; // total votes

php artisan vendor:publish --provider="Wikigods\Jraty\JratyServiceProvider"