-
Notifications
You must be signed in to change notification settings - Fork 0
/
ShowStars.php
42 lines (30 loc) · 905 Bytes
/
ShowStars.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
namespace maxiorphy\star_rating;
class ShowStars extends \yii\base\Widget
{
public $rating = 'rating';
public function run()
{
$rate = round($this->rating);
for ($i = 0; $i < $rate - 1; $i++) {
echo '<i class="fa fa-star gold-star"></i>';
}
if ($this->rating == 0) {
}
elseif($rate-$this->rating == 0){
echo '<i class="fa fa-star gold-star" ></i>';
}
elseif ($rate - $this->rating <= 0.0) {
echo '<i class="fa fa-star gold-star" ></i>';
}
elseif ($rate - $this->rating <= 0.5) {
echo '<i class="fa fa-star-half-alt gold-star" ></i>';
}
else {
echo '<i class="fa fa-star grey-star" ></i>';
}
for ($i = 0; $i < 5 - $rate; $i++) {
echo '<i class="fa fa-star grey-star"></i>';
}
}
}