/**
  * Displays a single ProductsBrands model.
  * @param integer $id
  * @return mixed
  */
 public function actionView($id)
 {
     $model = $this->findModel($id);
     $productsInfo = Products::getProductCode($model->productId);
     $brandName = Brandsmaster::getBrandName($model->brandId);
     $productCode = $productsInfo['productCode'];
     $model->productId = $productsInfo['productName'];
     $model->brandId = $brandName;
     $model->nutritionInfo = ProductNutrition::find()->where(['productCode' => $productCode, 'brandName' => $brandName])->one();
     return $this->render('view', ['model' => $model]);
 }
Exemple #2
0
use backend\models\Products;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\ProductsBrandsSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Products Brands';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="products-brands-index">

    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::a('Create Products Brands', ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'productId', 'label' => 'Product Name', 'value' => function ($data) {
    $productName = Products::getProductCode($data->productId);
    return $productName['productName'];
}], ['attribute' => 'brandId', 'label' => 'BrandName', 'value' => function ($data) {
    $brandName = Brandsmaster::getBrandName($data->brandId);
    return $brandName;
}], ['attribute' => 'productImage', 'format' => ['image', ['width' => '100', 'height' => '100']]], 'status', ['class' => 'yii\\grid\\ActionColumn']]]);
?>

</div>