My question is bit complex, I have tables name business, Items, busines_items and item_review.
我的问题有点复杂,我有表名业务,项目,busines_items和item_review。
Business has attributes business_id,business_name
Items has attributes item_id (pk), item_name,item_price,item_description
Business_Items has attributes business_items_id (pk), Business_id (fk),item_id, image
Item_review has attributes item_review_id (pk), business_items_id (fk), rating.
I want to show in a view of business, business_items_id from business_items table and rating of that item from item_review table.I have done some work, Through relationship i get the business_items_id. But How can i get the rating from item_review. so that when i go to this url localhost/project/business/products/business_id
this view shows me all the products of that business along with their ratings and picture.
我希望在业务视图中显示business_items表中的business_items_id以及item_review表中该项目的评级。我已经完成了一些工作,通过关系我获得了business_items_id。但是如何从item_review获得评级。所以,当我去这个网址localhost / project / business / products / business_id时,这个视图向我展示了该商家的所有产品以及他们的评级和图片。
My view file in business/viewitems
我在business / viewitems中的视图文件
<div class="container">
<div class="container">
<h1 class="page-title"><?php echo $model->business_name; ?>'s Products</h1> <!-- add this heading in page-tittle -->
</div>
<?php $item=$model->businessItems;
?>
<div class="row row-wrap">
<?php foreach($item as $ba)
{
// echo $ba->id;
?>
<div class="col-md-3">
<div class="thumb">
<header class="thumb-header">
<a class="hover-img" href="<?php Yii::app()->request->baseUrl?>/businessitems/itemspage/<?php echo $ba->id; ?>">
<img src="<?php Yii::app()->request->baseUrl?>/img/<?php echo $ba->image;?>" alt="Image Alternative text" title="Items" />
</a>
</header>
<div class="thumb-caption">
<h5 class="thumb-title"><a class="text-darken" href="<?php Yii::app()->request->baseUrl?>/businessitems/itemspage/<?php echo $ba->id; ?>"><?php echo $ba->items->item_name; ?></a></h5>
</div>
</div>
</div>
<?php } ?>
</div>
</div>
<div class="gap gap-small"></div>
</div>
Model of business
业务模式
<?php
/**
* This is the model class for table "business".
*
* The followings are the available columns in table 'business':
* @property integer $id
* @property string $business_name
* @property string $image
* @property string $business_description
* @property string $opening_hours
* @property string $closing_hours
* @property string $days
* @property string $Holiday
* @property string $website
* @property integer $phone
*
* The followings are the available model relations:
* @property Address[] $addresses
* @property BusinessItems[] $businessItems
* @property BusinessPackage[] $businessPackages
* * @property BusinessPhotos[] $businessPhotoses
* @property ClaimBusiness[] $claimBusinesses
* @property Facilities[] $facilities
* @property ReviewBusiness[] $reviewBusinesses
* @property SubCategoryBusiness[] $subCategoryBusinesses
*/
class Business extends CActiveRecord
{
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'business';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('business_name, business_description, opening_hours, closing_hours, days', 'required'),
array('phone', 'numerical', 'integerOnly'=>true),
array('business_name', 'length', 'max'=>60),
array('image, opening_hours, closing_hours, days, Holiday, website', 'length', 'max'=>45),
array('business_description', 'length', 'max'=>500),
// The following rule is used by search().
// @todo Please remove those attributes that should not be searched.
array('id, business_name, image, business_description, opening_hours, closing_hours, days, Holiday, website, phone', 'safe', 'on'=>'search'),
array('image', 'file','types'=>'jpg, gif, png', 'allowEmpty'=>true, 'safe' => false,'on'=>'insert,update'),
);
}
/**
* @return array relational rules.
*/
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'addresses' => array(self::HAS_MANY, 'Address', 'business_id'),
'businessItems' => array(self::HAS_MANY, 'BusinessItems', 'business_id'),
'businessPackages' => array(self::HAS_MANY, 'BusinessPackage', 'business_id'),
'businessPhotoses' => array(self::HAS_MANY, 'BusinessPhotos', 'business_id'),
'claimBusinesses' => array(self::HAS_MANY, 'ClaimBusiness', 'business_id'),
'facilities' => array(self::HAS_MANY, 'Facilities', 'business_id'),
'reviewBusinesses' => array(self::HAS_MANY, 'ReviewBusiness', 'business_id'),
'subCategoryBusinesses' => array(self::HAS_MANY, 'SubCategoryBusiness', 'business_id'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'id' => 'ID',
'business_name' => 'Business Name',
'image' => 'Image',
'business_description' => 'Business Description',
'opening_hours' => 'Opening Hours',
'closing_hours' => 'Closing Hours',
'days' => 'Days',
'Holiday' => 'Holiday',
'website' => 'Website',
'phone' => 'Phone',
);
}
/**
* Retrieves a list of models based on the current search/filter conditions.
*
* Typical usecase:
* - Initialize the model fields with values from filter form.
* - Execute this method to get CActiveDataProvider instance which will filter
* models according to data in model fields.
* - Pass data provider to CGridView, CListView or any similar widget.
*
* @return CActiveDataProvider the data provider that can return the models
* based on the search/filter conditions.
*/
public function search()
{
// @todo Please modify the following code to remove attributes that should not be searched.
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('business_name',$this->business_name,true);
$criteria->compare('image',$this->image,true);
$criteria->compare('business_description',$this->business_description,true);
$criteria->compare('opening_hours',$this->opening_hours,true);
$criteria->compare('closing_hours',$this->closing_hours,true);
$criteria->compare('days',$this->days,true);
$criteria->compare('Holiday',$this->Holiday,true);
$criteria->compare('website',$this->website,true);
$criteria->compare('phone',$this->phone);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
/**
* Returns the static model of the specified AR class.
* Please note that you should have this exact method in all your CActiveRecord descendants!
* @param string $className active record class name.
* @return Business the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
}
1 个解决方案
#1
-1
Any one who is interested in the answer here it goes. My business controller is given below.
任何对此答案感兴趣的人都会这样做。我的业务控制器如下。
public function actionViewitems($id)
{
//render main layout
$this->layout = 'main';
$rate = ItemReview::model()->findAll();
$this->render('viewitems', array(
'model' => $this->loadModel($id),
'rate' => $rate, //pass data
));
}
Now I can access it by using foreach
loop in my viewitems view.
现在我可以在我的viewitems视图中使用foreach循环来访问它。
foreach ($rate as $ba) {
echo $ba->rating;
}
Now given below is my view file, where i am getting specific rating against specific business and specific business items.
现在给出的是我的视图文件,我在其中获得针对特定业务和特定业务项的特定评级。
<div class="container">
<div class="container">
<h1 class="page-title"><?php echo $model->business_name; ?>'s Products</h1> <!-- add this heading in page-tittle -->
</div>
<?php
function name($percentage){
if($percentage==0 && $percentage<0.5)
{ ?> <div class="booking-item-rating">
<ul class="icon-list icon-group booking-item-rating-stars">
<li><div class="rating_subcat">
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-off.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-off.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-off.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-off.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-off.png";?>">;
</div>
</li>
</ul>
</div>
<?php }
elseif ($percentage>=0.5 && $percentage<1) { ?>
<div class="booking-item-rating">
<ul class="icon-list icon-group booking-item-rating-stars">
<li><div class="rating_subcat">
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-off.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-half.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-off.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-off.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-off.png";?>">;
</div>
</li>
</ul>
</div>
<?php }
elseif ($percentage>=1 && $percentage<1.5) { ?> <div class="booking-item-rating"><ul class="icon-list icon-group booking-item-rating-stars"><li><div class="rating_subcat">
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-on.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-off.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-off.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-off.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-off.png";?>">;
</div>
</li>
</ul>
</div>
<?php }
elseif ($percentage>=1.5 && $percentage<2) { ?> <div class="booking-item-rating"><ul class="icon-list icon-group booking-item-rating-stars"><li><div class="rating_subcat">
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-on.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-half.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-off.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-off.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-off.png";?>">;
</div>
</li>
</ul>
</div>
<?php }
elseif ($percentage>=2 && $percentage<2.5) { ?> <div class="booking-item-rating"><ul class="icon-list icon-group booking-item-rating-stars"><li><div class="rating_subcat">
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-on.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-on.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-off.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-off.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-off.png";?>">;
</div>
</li>
</ul>
</div>
<?php }
elseif ($percentage>=2.5 && $percentage<3) { ?> <div class="booking-item-rating"><ul class="icon-list icon-group booking-item-rating-stars"><li><div class="rating_subcat">
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-on.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-on.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-half.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-off.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-off.png";?>">;
</div>
</li>
</ul>
</div>
<?php }
elseif ($percentage>=3 && $percentage<3.5) { ?> <div class="booking-item-rating"><ul class="icon-list icon-group booking-item-rating-stars"><li><div class="rating_subcat">
<div class="rating">
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-on.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-on.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-on.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-off.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-off.png";?>">;
</div>
</div>
</li>
</ul>
</div>
<?php }
elseif ($percentage>=3.5 && $percentage<4) { ?> <div class="booking-item-rating"><ul class="icon-list icon-group booking-item-rating-stars"><li><div class="rating_subcat">
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-on.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-on.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-on.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-half.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-off.png";?>">;
</div>
</li>
</ul>
</div>
<?php }
elseif ($percentage>=4 && $percentage<4.5) { ?> <div class="booking-item-rating"><ul class="icon-list icon-group booking-item-rating-stars"><li><div class="rating_subcat">
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-on.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-on.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-on.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-on.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-off.png";?>">;
</div>
</li>
</ul>
</div>
<?php }
elseif ($percentage>=4.5 && $percentage<5) { ?> <div class="booking-item-rating"><ul class="icon-list icon-group booking-item-rating-stars"><li><div class="rating_subcat">
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-on.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-on.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-on.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-on.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-half.png";?>">;
</div>
</li>
</ul>
</div>
<?php }
elseif ($percentage=5) { ?> <div class="booking-item-rating"><ul class="icon-list icon-group booking-item-rating-stars"><li><div class="rating_subcat">
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-on.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-on.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-on.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-on.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-on.png";?>">;
</div>
</li>
</ul>
</div>
<?php }
}
?>
<?php $item=$model->businessItems;
?>
<div class="row row-wrap">
<?php foreach($item as $ba)
{
$bizitems=$ba->id; //getting id of business items
$biz=$ba->business_id; //business id from model business items
$value=$model->id; //storing business id of current business
if($value==$biz){ //matching business id and business id from busienss items table
$image=$ba->image; //geting image from business items table
$item_name=$ba->items->item_name;
$sum=0;
$time=0;
?>
<div class="col-md-3">
<div class="thumb">
<header class="thumb-header">
<a class="hover-img" href="<?php Yii::app()->request->baseUrl?>/businessitems/itemspage/<?php echo $bizitems; ?>">
<img src="<?php Yii::app()->request->baseUrl?>/img/<?php echo $image;?>" alt="Image Alternative text" title="Items" />
</a>
</header>
<?php
foreach ($rate as $ab){
$ratebiz=$ab->business_items_id; //getting business items id from item review
if($ratebiz==$bizitems){ //comparing business items id with business items id in item review
$sum=$sum+$ab->rating;
$time++;
}
}?>
<div class="thumb-caption">
<ul class="icon-group text-tiny text-color">
<?php if($time!=0)
{
$percentage=$sum/$time;
} ?>
<?php name($percentage);//echo $percentage; //showing rating ?>
</ul>
<h5 class="thumb-title"><a class="text-darken" href="<?php Yii::app()->request->baseUrl?>/businessitems/itemspage/<?php echo $ba->id; ?>"><?php echo $ba->items->item_name; ?></a></h5>
</div>
</div>
</div>
<?php } } ?>
</div>
</div>
<div class="gap gap-small"></div>
</div>
#1
-1
Any one who is interested in the answer here it goes. My business controller is given below.
任何对此答案感兴趣的人都会这样做。我的业务控制器如下。
public function actionViewitems($id)
{
//render main layout
$this->layout = 'main';
$rate = ItemReview::model()->findAll();
$this->render('viewitems', array(
'model' => $this->loadModel($id),
'rate' => $rate, //pass data
));
}
Now I can access it by using foreach
loop in my viewitems view.
现在我可以在我的viewitems视图中使用foreach循环来访问它。
foreach ($rate as $ba) {
echo $ba->rating;
}
Now given below is my view file, where i am getting specific rating against specific business and specific business items.
现在给出的是我的视图文件,我在其中获得针对特定业务和特定业务项的特定评级。
<div class="container">
<div class="container">
<h1 class="page-title"><?php echo $model->business_name; ?>'s Products</h1> <!-- add this heading in page-tittle -->
</div>
<?php
function name($percentage){
if($percentage==0 && $percentage<0.5)
{ ?> <div class="booking-item-rating">
<ul class="icon-list icon-group booking-item-rating-stars">
<li><div class="rating_subcat">
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-off.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-off.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-off.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-off.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-off.png";?>">;
</div>
</li>
</ul>
</div>
<?php }
elseif ($percentage>=0.5 && $percentage<1) { ?>
<div class="booking-item-rating">
<ul class="icon-list icon-group booking-item-rating-stars">
<li><div class="rating_subcat">
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-off.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-half.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-off.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-off.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-off.png";?>">;
</div>
</li>
</ul>
</div>
<?php }
elseif ($percentage>=1 && $percentage<1.5) { ?> <div class="booking-item-rating"><ul class="icon-list icon-group booking-item-rating-stars"><li><div class="rating_subcat">
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-on.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-off.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-off.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-off.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-off.png";?>">;
</div>
</li>
</ul>
</div>
<?php }
elseif ($percentage>=1.5 && $percentage<2) { ?> <div class="booking-item-rating"><ul class="icon-list icon-group booking-item-rating-stars"><li><div class="rating_subcat">
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-on.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-half.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-off.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-off.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-off.png";?>">;
</div>
</li>
</ul>
</div>
<?php }
elseif ($percentage>=2 && $percentage<2.5) { ?> <div class="booking-item-rating"><ul class="icon-list icon-group booking-item-rating-stars"><li><div class="rating_subcat">
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-on.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-on.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-off.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-off.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-off.png";?>">;
</div>
</li>
</ul>
</div>
<?php }
elseif ($percentage>=2.5 && $percentage<3) { ?> <div class="booking-item-rating"><ul class="icon-list icon-group booking-item-rating-stars"><li><div class="rating_subcat">
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-on.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-on.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-half.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-off.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-off.png";?>">;
</div>
</li>
</ul>
</div>
<?php }
elseif ($percentage>=3 && $percentage<3.5) { ?> <div class="booking-item-rating"><ul class="icon-list icon-group booking-item-rating-stars"><li><div class="rating_subcat">
<div class="rating">
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-on.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-on.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-on.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-off.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-off.png";?>">;
</div>
</div>
</li>
</ul>
</div>
<?php }
elseif ($percentage>=3.5 && $percentage<4) { ?> <div class="booking-item-rating"><ul class="icon-list icon-group booking-item-rating-stars"><li><div class="rating_subcat">
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-on.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-on.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-on.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-half.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-off.png";?>">;
</div>
</li>
</ul>
</div>
<?php }
elseif ($percentage>=4 && $percentage<4.5) { ?> <div class="booking-item-rating"><ul class="icon-list icon-group booking-item-rating-stars"><li><div class="rating_subcat">
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-on.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-on.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-on.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-on.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-off.png";?>">;
</div>
</li>
</ul>
</div>
<?php }
elseif ($percentage>=4.5 && $percentage<5) { ?> <div class="booking-item-rating"><ul class="icon-list icon-group booking-item-rating-stars"><li><div class="rating_subcat">
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-on.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-on.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-on.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-on.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-half.png";?>">;
</div>
</li>
</ul>
</div>
<?php }
elseif ($percentage=5) { ?> <div class="booking-item-rating"><ul class="icon-list icon-group booking-item-rating-stars"><li><div class="rating_subcat">
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-on.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-on.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-on.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-on.png";?>">;
<img src="<?php echo Yii::app()->request->baseUrl;?>/img/<?php echo "star-on.png";?>">;
</div>
</li>
</ul>
</div>
<?php }
}
?>
<?php $item=$model->businessItems;
?>
<div class="row row-wrap">
<?php foreach($item as $ba)
{
$bizitems=$ba->id; //getting id of business items
$biz=$ba->business_id; //business id from model business items
$value=$model->id; //storing business id of current business
if($value==$biz){ //matching business id and business id from busienss items table
$image=$ba->image; //geting image from business items table
$item_name=$ba->items->item_name;
$sum=0;
$time=0;
?>
<div class="col-md-3">
<div class="thumb">
<header class="thumb-header">
<a class="hover-img" href="<?php Yii::app()->request->baseUrl?>/businessitems/itemspage/<?php echo $bizitems; ?>">
<img src="<?php Yii::app()->request->baseUrl?>/img/<?php echo $image;?>" alt="Image Alternative text" title="Items" />
</a>
</header>
<?php
foreach ($rate as $ab){
$ratebiz=$ab->business_items_id; //getting business items id from item review
if($ratebiz==$bizitems){ //comparing business items id with business items id in item review
$sum=$sum+$ab->rating;
$time++;
}
}?>
<div class="thumb-caption">
<ul class="icon-group text-tiny text-color">
<?php if($time!=0)
{
$percentage=$sum/$time;
} ?>
<?php name($percentage);//echo $percentage; //showing rating ?>
</ul>
<h5 class="thumb-title"><a class="text-darken" href="<?php Yii::app()->request->baseUrl?>/businessitems/itemspage/<?php echo $ba->id; ?>"><?php echo $ba->items->item_name; ?></a></h5>
</div>
</div>
</div>
<?php } } ?>
</div>
</div>
<div class="gap gap-small"></div>
</div>