public function getUser() { if ($this->_user === false) { $this->_user = Admin::findByUsername($this->username); } return $this->_user; }
public function actionDelete($id) { if ($model = Admin::findOne($id)) { $model->delete(); } else { $this->error = Yii::t('easyii', 'Not found'); } return $this->formatResponse(Yii::t('easyii', 'Admin deleted')); }
public function down() { $this->dropTable(models\Admin::tableName()); $this->dropTable(models\LoginForm::tableName()); $this->dropTable(models\Module::tableName()); $this->dropTable(models\Photo::tableName()); $this->dropTable(models\Setting::tableName()); $this->dropTable(Carousel::tableName()); $this->dropTable(Category::tableName()); $this->dropTable(Item::tableName()); $this->dropTable(Feedback::tableName()); $this->dropTable(File::tableName()); $this->dropTable(Album::tableName()); $this->dropTable(Guestbook::tableName()); $this->dropTable(News::tableName()); $this->dropTable(Page::tableName()); $this->dropTable(Subscriber::tableName()); $this->dropTable(History::tableName()); $this->dropTable(Text::tableName()); }
private function createItemObject($data) { $temp = (object) ['id' => $data['item_id'], 'category' => $data['category_id'], 'slug' => $data['slug'], 'title' => $data['title'], 'thumb' => $data['thumb'], 'description' => $data['description'], 'created_at' => $data['created_at'], 'updated_at' => $data['updated_at'], 'created_by' => $data['created_by'], 'updated_by' => $data['updated_by'], 'createdBy' => Admin::findOne($data['created_by']), 'updatedBy' => Admin::findOne($data['updated_by'])]; foreach ($data['data'] as $key => $value) { $temp->{$key} = $value; } return $temp; }
private function createObject($data) { $is_string = !is_array($data); return (object) ['id' => $is_string ? '' : $data['news_id'], 'thumb' => $is_string ? '' : $data['thumb'], 'title' => $is_string ? $data : $data['title'], 'short' => $is_string ? $data : $data['short'], 'text' => $is_string ? $data : $data['text'], 'slug' => $is_string ? '' : $data['slug'], 'views' => $is_string ? '' : $data['views'], 'time' => $is_string ? '' : $data['time'], 'date' => $is_string ? '' : Yii::$app->formatter->asDatetime($data['time'], 'medium'), 'empty' => $is_string ? true : false, 'created_by' => $is_string ? '' : $data['created_by'], 'updated_by' => $is_string ? '' : $data['updated_by'], 'createdBy' => $is_string ? '' : Admin::findOne($data['created_by']), 'updatedBy' => $is_string ? '' : Admin::findOne($data['updated_by'])]; }
private function createItemObject($data) { return (object) ['id' => $data['item_id'], 'category' => $data['category_id'], 'title' => $data['title'], 'short' => $data['short'], 'text' => $data['text'], 'thumb' => $data['thumb'], 'views' => $data['views'], 'slug' => $data['slug'], 'created_by' => $is_string ? '' : $data['created_by'], 'updated_by' => $is_string ? '' : $data['updated_by'], 'createdBy' => $is_string ? '' : Admin::findOne($data['created_by']), 'updatedBy' => $is_string ? '' : Admin::findOne($data['updated_by'])]; }
public function down() { $this->dropTable(models\Admin::tableName()); $this->dropTable(models\LoginForm::tableName()); $this->dropTable(models\Module::tableName()); $this->dropTable(models\Photo::tableName()); $this->dropTable(models\Setting::tableName()); $this->dropTable(Carousel::tableName()); $this->dropTable(catalog\models\Category::tableName()); $this->dropTable(catalog\models\Item::tableName()); $this->dropTable(article\models\Category::tableName()); $this->dropTable(article\models\Item::tableName()); $this->dropTable(Feedback::tableName()); $this->dropTable(File::tableName()); $this->dropTable(gallery\models\Category::tableName()); $this->dropTable(Guestbook::tableName()); $this->dropTable(News::tableName()); $this->dropTable(Page::tableName()); $this->dropTable(Subscriber::tableName()); $this->dropTable(History::tableName()); $this->dropTable(Text::tableName()); $this->dropTable(Menu::tableName()); $this->dropTable(MenuItem::tableName()); }
public function getCreatedBy() { return $this->hasOne(Admin::className(), ['admin_id' => 'created_by']); }