yii2

Swiftmailer in Yii2 - Unable to send email

北慕城南 提交于 2020-01-06 02:43:05
问题 I'm using basic Yii2 template and Swiftmailer to send email.. Here is my code for config/web.php : 'mailer' => [ 'class' => 'yii\swiftmailer\Mailer', // send all mails to a file by default. You have to set // 'useFileTransport' to false and configure a transport // for the mailer to send real emails. 'useFileTransport'=>'false', 'transport' => [ 'class' => 'Swift_SmtpTransport', 'host' => 'smtp.gmail.com', 'username' => 'myemail@gmail.com', 'password' => 'password', 'port' => '587',

error: Call to a member function validatePassword() on a non-object (yii2)

安稳与你 提交于 2020-01-05 22:23:36
问题 I'm new in this framework actually this is my first time to use framework. Can someone help me on this error I don't know how to fixed this error. here is my code: User.php: <?php namespace app\models; use Yii; class User extends \yii\db\ActiveRecord implements \yii\web\IdentityInterface { public $id; public $username; public $password; public $authKey; public $accessToken; public static function tableName() { return 'user_file'; } /** * @inheritdoc */ public static function findIdentity($id)

error: Call to a member function validatePassword() on a non-object (yii2)

故事扮演 提交于 2020-01-05 22:18:44
问题 I'm new in this framework actually this is my first time to use framework. Can someone help me on this error I don't know how to fixed this error. here is my code: User.php: <?php namespace app\models; use Yii; class User extends \yii\db\ActiveRecord implements \yii\web\IdentityInterface { public $id; public $username; public $password; public $authKey; public $accessToken; public static function tableName() { return 'user_file'; } /** * @inheritdoc */ public static function findIdentity($id)

Yii2 BackOffice with API REST Implementation

廉价感情. 提交于 2020-01-05 10:08:51
问题 I have developed an app in Yii2 that is as a backoffice for a Travel Agency. I have used the basic start template, and used gii (code generator) to create the CRUDS for the models (Hotels, HotelRooms, HotelImages, etc) I also want to create two different front-end applications (one for retail, and the other for other agencies), and I thought to separate it from the backend (maybe an angular.js app) and get the info through REST could be a good approach. So I want to use the API Rest based on

How i can force an yii2 module to use a specific connection for all his models?

这一生的挚爱 提交于 2020-01-05 07:04:15
问题 on a module I have add a component named db where i put, like the main Yii component, the data for database connection, I need in my module use everytime the db specified in his configuration for all models and not the main database connection, how I can do this? 回答1: You have several way eg. using a separated configuration in app/config/main.php eg adding a specific dbMyMod to component config return [ // ... 'components' => [ // ... 'db' => [ 'class' => 'yii\db\Connection', 'dsn' => 'mysql

Yii2 How to access a folder in “root” folder?

六月ゝ 毕业季﹏ 提交于 2020-01-05 05:47:05
问题 I have made a website with Yii2 advanced template and I want to access files in the upload folder located in the "root" folder. I have : backend/web/ frontend/web/ uploads/ I have followed the 1st answer of Yii2. Access to higher level folder So my .htaccess is Options +FollowSymlinks RewriteEngine On # deal with backend first RewriteCond %{REQUEST_URI} /(backend) RewriteRule ^backend/assets/(.*)$ backend/web/assets/$1 [L] RewriteRule ^backend/css/(.*)$ backend/web/css/$1 [L] RewriteRule

Yii2 Saving tabular data using yii2-formwizard

ぐ巨炮叔叔 提交于 2020-01-05 05:36:06
问题 I am integrating yii2-formwizard for tabular input but unable to submit the data to my controller action and use Model::loadMultiple . I have to declare my model as array and then I need to initialize it before passing to view and in buttflattery/yii2-formwizard front-end I must specify my model as array fine but I can not retrieve data from my controller dynamically. I need to dynamically create instance from front-end and save them in back end. I can save only the instance I have initialize

Returning raw query as array yii 2

萝らか妹 提交于 2020-01-05 05:32:52
问题 Hello how do I return a raw query into an array in yii 2? I have been working on this code and I assume that it should return multiple rows but when I try to a foreach on a view it it says that Invalid argument supplied for foreach() Here is the error page: Here is the code I am working on Model public function Showprerequisites($trno){ // $connection = Yii::$app->GetDb(); return Yii::$app->db->CreateCommand(' SELECT * FROM ( SELECT pre1 AS col FROM ccsubject WHERE trno = 29005 AND pre1 IS

Saving data in the database in yii2 during file upload action

女生的网名这么多〃 提交于 2020-01-05 05:08:12
问题 I have a upload controller where by am also performing saving other data to the database. The file uploading to the folder is okay but saving the other details in the table doesn't happen controller code $images = $_FILES['evidence']; $success = null; $paths= ['uploads']; // get file names $filenames = $images['name']; // loop and process files for($i=0; $i < count($filenames); $i++){ //$ext = explode('.', basename($filenames[$i])); $target = "uploads/cases/evidence".DIRECTORY_SEPARATOR . md5

yii2 Fullcalendar - Why is alert for CalEvent working but not for updating innerHtml?

微笑、不失礼 提交于 2020-01-05 04:54:51
问题 I am using philippfrenzel/yii2fullcalendar and I want to show the event description. when I am using the code: <script> var JSEventClick = (function(calEvent, jsEvent, view) { // document.getElementsByClassName('.fc-title').innerHtml += 'calEvent.nonstandard.field1' ; alert(calEvent.title + ' -- ' + calEvent.nonstandard.field1); }); </script> it is working fine. but when I am using: <script> var JSEventClick = (function(calEvent, jsEvent, view) { document.getElementsByClassName('.fc-title')