This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if(isset($argv[1]) && $argv[1] !=null && isset($argv[2]) && $argv[2] !=null ){ | |
$start_arr = explode('/',$argv[1]); | |
$end_arr = explode('/',$argv[2]); | |
$start_date = $start_arr[2].'-'.$start_arr[1].'-'.$start_arr[0]; | |
$end_date = $end_arr[2].'-'.$end_arr[1].'-'.$end_arr[0]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery.validator.addMethod("alphanumeric", function(value, element) { // allow only alpha numric validation | |
return this.optional(element) || /^[a-zA-Z0-9]+$/.test(value); | |
}); | |
jQuery.validator.addMethod("letterwithspaces", function(value, element) { // allow only latters with space validation | |
return this.optional(element) || /^[a-zA-Z]+$/.test(value); | |
}); | |
jQuery.validator.addMethod("imagetype", function(value, element) { // allow image validation | |
return this.optional(element) || /^.*\.(jpg|png|jpeg|gif)$/i.test(value); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Yii::$app->errorHandler->errorAction = 'studconsult/default/error'; | |
<?php | |
namespace app\modules\admin; | |
class Module extends \yii\base\Module | |
{ | |
public $controllerNamespace = 'app\modules\admin\controllers'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace app\modules\admin; | |
class Module extends \yii\base\Module | |
{ | |
public $controllerNamespace = 'app\modules\admin\controllers'; | |
public function init() | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. by model : | |
[['attribute', 'second_attribute'], 'default', 'value' => 'something_here'], | |
2. load attributes in model | |
$model = new Post(); | |
$model->loadDefaultValues(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SMTP settings to send mail in yii2 | |
'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', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// To create custom admin layout template , Go to config/web.php and add below lines | |
'modules' => [ | |
'gii' => [ | |
'class' => 'yii\gii\Module', //adding gii module | |
'allowedIPs' => ['127.0.0.1','192.168.1.*'], //allowing ip's | |
'generators' => [ | |
'crud' => [ // generator name | |
'class' => 'yii\gii\generators\crud\Generator', // generator class | |
'templates' => [ //setting for out templates |