public function run() { DB::statement("TRUNCATE TABLE business_categories"); $category = new BusinessCategory(); $category->name = 'Category one'; $category->created_at = new DateTime(); $category->updated_at = new DateTime(); $category->save(); $category = new BusinessCategory(); $category->name = 'Category two'; $category->created_at = new DateTime(); $category->updated_at = new DateTime(); $category->save(); }
public function loadModel($id) { $model = BusinessCategory::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, Yii::t('app', 'The requested page does not exist.')); } return $model; }
public function getTree() { $allCategories = BusinessCategory::model()->findAll(); $whole = Awecms::buildTree(Awecms::quickSort($allCategories)); $part = self::getNode($whole, $this->id); // print_r($part); // die(); return array($part); }
/** * Update the specified outlet in storage. * * @param int $id * @return Response */ public function update($id) { $retailer = Retailer::findOrFail($id); $validator = Validator::make($data = Input::all(), Retailer::$rules); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } $retailer->update($data); $countries = Country::lists('country', 'id'); $cities = City::where('country_id', $retailer->country_id)->lists('city', 'id'); $addresses = Address::where('city_id', $retailer->city_id)->lists('address', 'id'); $cats = BusinessCategory::lists('name', 'id'); return Redirect::to('admin/retailers/' . $retailer->id . '/edit')->with('success', 'Update retailer'); }
<?php echo $form->labelEx($model, 'image'); ?> <?php // echo $form->textField($model, 'image', array('size' => 60, 'maxlength' => 60)); echo CHtml::activeFileField($model, 'image'); echo $form->error($model, 'image'); ?> </div> <div class="row nm_row"> <label for="businessCategories"><?php echo Yii::t('app', 'Business Categories'); ?> </label> <br /> <?php echo CHtml::checkBoxList('Business[businessCategories]', array_map('Awecms::getPrimaryKey', $model->businessCategories), CHtml::listData(BusinessCategory::model()->findAll(), 'id', 'title'), array('attributeitem' => 'id')); ?> </div> <div class="row buttons"> <?php echo CHtml::submitButton(Yii::t('app', 'Save')); echo CHtml::Button(Yii::t('app', 'Cancel'), array('submit' => 'javascript:history.go(-1)')); ?> </div> <?php $this->endWidget(); ?> </div> <!-- form -->
public static function getKeyValueData() { return BusinessCategory::lists('name', 'id'); }