yii2-advanced-app

How to set separate homeUrl for authenticated users and guests in yii2

我与影子孤独终老i 提交于 2019-12-12 03:49:48
问题 I'm wondering is it possible to make different homeUrl for authenticated and guest users? I have such rules in SiteController.php public function behaviors() { return [ 'access' => [ 'class' => AccessControl::className(), 'only' => ['logout', 'signup'], 'rules' => [ [ 'actions' => ['signup'], 'allow' => true, 'roles' => ['?'], 'denyCallback' => function() { return $this->redirect('/account'); } ], [ 'actions' => ['logout', 'condition'], 'allow' => true, 'roles' => ['@'], ], ], ], 'verbs' => [

How to create a dropdown dependent on another dropdown in yii2?

我的未来我决定 提交于 2019-12-12 03:25:22
问题 I have two api's: 1: returns all the industries, 2: returns all the industry category(based on industry id). I need two dropdowns, one dependent on other. On selecting industry 2nd dropdown should show only relevant categories. Thanks in advance. 回答1: I got it. I have simply used ajax which posts the value from one dropdown and sends the data to an action which returns the data and i am simply putting those values to my other drop down. :) 回答2: <?= $form->field($model, 'industryId')-

composer works every where except one project

回眸只為那壹抹淺笑 提交于 2019-12-12 03:03:44
问题 I'm beginner in yii2. composer command works in every path in windows 10, but in one of my project's path composer command not works. Actually does nothing at all. It's obviously in this image: I don't know the the reason. My composer.json: { "name": "yiisoft/yii2-app-advanced", "description": "Yii 2 Advanced Project Template", "keywords": ["yii2", "framework", "advanced", "project template"], "homepage": "http://www.yiiframework.com/", "type": "project", "license": "BSD-3-Clause", "support":

Yii2: how to display images from backend/web to frontend in advanced app

放肆的年华 提交于 2019-12-12 01:22:46
问题 I need to display 1 (first) image which path is saved in database like Img1.jpg;img2.jpg; , I tried to seperate each path by using explode , getting all the images as array but not able to pick single path- <div class="col-sm-6 masonry-item"> <a href="<?php echo Url::to(['site/roompage']); ?>" class="product_item text-center"> <span class="product_photo bordered_wht_border"> <?php foreach (explode(';',rtrim($row['images'],';'),1) as $key_img => $value_img) { ?> <?php echo Html::img('@backend

Yii2: How to use backend web folders files in frontend

◇◆丶佛笑我妖孽 提交于 2019-12-11 19:16:21
问题 I have many images in backends web folder, I want to use those images in frontend how to get those files? I need to display 1 (first) image which path is saved in database like Img1.jpg;img2.jpg; <?php foreach (explode(';',rtrim($row['images'],';'),1) as $key_img => $value_img) { ?> <?php echo Html::img('@backend/web'.'/'.$value_img);?> <?php } ?> 回答1: <?= \yii\helpers\Html::img('@backend/web/images/your-image.jpg') ?> The src parameter, containing the backend alias, will be processed by Url:

yii2 with dhtmlx scheduler and select populated from the server

∥☆過路亽.° 提交于 2019-12-11 17:17:01
问题 I am trying to populate the project select dropdown with data from the server. I am using yii2. My controller data action: public function actionData() { $list = new OptionsConnector(null, "PHPYii"); $list->render_table("project", "id", "id(value),name(label)"); $connector = new JSONSchedulerConnector(null, "PHPYii"); $connector->set_options("project", $list); $connector->configure( new Booking(), "id", "start, end, activity, user, subsubproject, status, comment" ); $connector->render(); } I

How to pass subquery as table name to another query in yii2

北城以北 提交于 2019-12-11 14:18:08
问题 I have a query which I am trying to convert into yii2 syntax. Below is the query SELECT project_id, user_ref_id FROM ( SELECT `project_id`, `user_ref_id` FROM `projectsList` WHERE user_type_ref_id = 1) AS a WHERE user_ref_id = '.yii::$app->user->id; I am trying to convert it into yii2 format like $subQuery = (new Query())->select(['p.project_id', 'p.user_ref_id'])->from('projectsList')->where(['user_type_ref_id' => 1]); $uQuery = (new Query())->select(['p.project_id', 'p.user_ref_id'])->from(

How to update multiple images in kartik Upload widget?

偶尔善良 提交于 2019-12-11 14:07:51
问题 Here i can only able preview the images on update the model. I want to load the images properly so user can remove one r more file and update will work accordingly Here is my controller public function actionUpdate($id) { $model = $this->findModel($id); $session_data = \common\models\Customer::find()->where(['user_id' => $model->customer_user_id])->one(); $towing = \common\models\TowingRequest::find()->where(['id' => $model->towing_request_id])->one(); $images_old = \common\models\Images:

Yii2 - How to set Time in Log messages?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-11 10:16:54
问题 I am using EmailTarget in Yii2 and I am logging messages like this. Yii::info('Log message example','mail'); After successful execution, I am receiving mail like this: 2018-07-31 09:01:12 [127.0.0.1][user@example.com][-][info][mail] Log message example By default Yii2 generating log messages and displaying time in GMT format. How can I configure time in these log messages? 回答1: This log target uses date() for date formatting, so if you're getting date with wrong timezone, you probably have

after make or change password User dont login in Yii2

微笑、不失礼 提交于 2019-12-11 08:54:01
问题 after make or edit password User i have login error 'Incorrect username or password' in Yii2 login with user 'admin' is work ( i make admin user with actionCreate1) auth_key: kYm0pvYAXY4IzuV7eYgGgtjSqoxxMNUL password: $2y$13$QqsbMW3ErXwWOPad3abDYOPzh5XLwuEvQKBhZGEEDoT0Av5l0bE2S but i make user or edit password , in login page i have error: 'Incorrect username or password' i think problem from beforeSave in Model USER User Table: id int auth_key text username text password text actionCreate: