本文整理汇总了PHP中app\models\Categories::load方法的典型用法代码示例。如果您正苦于以下问题:PHP Categories::load方法的具体用法?PHP Categories::load怎么用?PHP Categories::load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Categories
的用法示例。
在下文中一共展示了Categories::load方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionCreate
/**
* Creates a new Categories model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Categories();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'alias' => $model->slugUrl]);
} else {
return $this->render('create', ['model' => $model]);
}
}
示例2: actionCreate
/** Создание нового раздела
*/
public function actionCreate($cat_id = 0)
{
$model = new Categories();
$model->attachBehavior('createStoreDir', ['class' => StoreDirBehavior::className(), 'handlerName' => 'gallery']);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect([$model->handler . '/list', 'id' => $model->id]);
} else {
$model->parent_id = $cat_id;
return $this->render('create', ['model' => $model]);
}
}
示例3: actionCreate
/**
* Creates a new Categories model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate($categoryId = null)
{
$categories = Categories::find()->all();
$model = new Categories();
$model->parent_category_id = $categoryId;
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'categoryId' => $model->category_id]);
} else {
return $this->render('create', ['model' => $model, 'categories' => $categories]);
}
}
示例4: actionCreate
/**
* Creates a new Categories model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Categories();
$model->active = true;
$model->updated_at = date("Y-m-d H:i:s");
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('create', ['model' => $model]);
}
}
示例5: actionCreate
/**
* Creates a new Resources model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate($id)
{
if ($id == 0) {
throw new \yii\web\BadRequestHttpException("Неправильный запрос");
}
$model = new Categories();
$model->parent_id = $id;
$model->handler = $this->id;
$model->attachBehavior('createStoreDir', ['class' => StoreDirBehavior::className(), 'handlerName' => $this->id]);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['list', 'id' => $model->parent_id]);
} else {
return $this->render('create', ['model' => $model]);
}
}
示例6: actionCreate
/**
* Создание корневой категории
* @return string
* @TODO добавление title
*/
public function actionCreate()
{
$model = new Categories();
if ($model->load(Yii::$app->request->post())) {
if (Yii::$app->request->post('Categories')['rootCat'] === '') {
$model = new Categories(['name' => Yii::$app->request->post('Categories')['name'], 'site_id' => Yii::$app->request->post('Categories')['site_id'], 'title' => Yii::$app->request->post('Categories')['title'], 'cssclass' => md5(time()), 'action' => Yii::$app->request->post('Categories')['action']]);
$model->makeRoot();
} else {
$model = new Categories(['name' => Yii::$app->request->post('Categories')['name'], 'site_id' => Yii::$app->request->post('Categories')['site_id'], 'title' => Yii::$app->request->post('Categories')['title'], 'cssclass' => md5(time()), 'action' => Yii::$app->request->post('Categories')['action']]);
$rootCategory = Categories::find()->where(['id' => Yii::$app->request->post('Categories')['rootCat']])->one();
//var_dump(Yii::$app->request->post('Categories')); exit;
$model->prependTo($rootCategory);
}
return $this->redirect(Url::toRoute('categories/index'));
} else {
return $this->render('_form', ['model' => $model]);
}
}
示例7: actionCreate
/**
* Creates a new Categories model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
if (\Yii::$app->user->isGuest) {
return $this->goHome();
}
$model = new Categories();
$indicatorsAvailable = IndicatorNames::find()->select(['name', 'id'])->indexBy('id')->column();
$indicatorsPresent = [];
if ($model->load(Yii::$app->request->post()) && $model->save()) {
foreach (Yii::$app->request->post()['Categories']['indicators'] as $id_indicator) {
$catInd = new CategoriesIndicators();
$catInd->id_indicator_names = $id_indicator;
$catInd->id_categories = $model->id;
$catInd->save();
}
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('create', ['model' => $model, 'indicatorsAvailable' => $indicatorsAvailable, 'indicatorsPresent' => $indicatorsPresent]);
}
}
示例8: actionCreate
/**
* Creates a new Categories model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Categories();
if ($model->load(Yii::$app->request->post())) {
$image = UploadedFile::getInstance($model, 'photo_name');
$model->photo_name = $image->name;
$model->save();
if ($image != null) {
$imagePath = explode("\\", $image->tempName);
array_pop($imagePath);
$imagePath = implode("\\", $imagePath);
$imagePath = $imagePath . "\\" . $image->name;
$image->saveAs($imagePath);
$model->attachImage($imagePath, true);
} else {
$model->removeImage($model->getImage(), true);
}
$model->save();
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('create', ['model' => $model]);
}
}
示例9: actionUpdate
public function actionUpdate($id = null)
{
$model = new Categories();
if ($model->load($_POST)) {
$id = $_POST['Categories']['id'];
if ($id) {
$model = Categories::findOne($id);
$model->attributes = $_POST['Categories'];
}
if ($model->save()) {
return $this->redirect(['index', 'langs' => $_POST['Categories']['langs']]);
} else {
print_r($model->getErrors());
exit;
}
}
if ($id) {
$model = Categories::findOne($id);
} else {
$model->langs = $_REQUEST['langs'];
}
return $this->render('update', ['model' => $model]);
}
示例10: actionUpdate
public function actionUpdate($id = null)
{
$model = new Categories();
if ($model->load(Yii::$app->request->post())) {
$request = Yii::$app->request->post('Categories');
$id = $request['id'];
if ($id) {
$model = Categories::findOne($id);
$model->attributes = $request;
}
if ($model->save()) {
return $this->redirect(['index', 'langs' => $request['langs']]);
} else {
print_r($model->getErrors());
exit;
}
}
if ($id) {
$model = Categories::findOne($id);
} else {
$model->langs = Yii::$app->getRequest()->getQueryParam('langs', 'thai');
}
return $this->render('update', ['model' => $model]);
}