admin

Categories:

alt
Name: Facebook
Parent: Social
Posts: 2
alt
Name: Tumblr
Parent: Social
Posts: 1
alt
Name: Ubuntu
Parent: Linux
Posts: 13
alt
Name: Linux
Parent: No category
Posts: 1
alt
Name: Content
Parent: No category
Posts: 2
alt
Name: Google Chrome
Parent: Google
Posts: 1
alt
Name: YouTube
Parent: Social
Posts: 1
alt
Name: Composer
Parent: No category
Posts: 4
alt
Name: Codeigniter
Parent: Framework
Posts: 1
alt
Name: Laravel
Parent: Framework
Posts: 5
alt
Name: Notepad++
Parent: IDE
Posts: 1
alt
Name: XAMPP
Parent: Server
Posts: 2
alt
Name: NetBeans
Parent: IDE
Posts: 3
alt
Name: Google Maps API
Parent: Google
Posts: 1
alt
Name: iPage.com
Parent: Hosting
Posts: 1
alt
Name: DHTMLX
Parent: No category
Posts: 1
alt
Name: Git, Git Bash
Parent: No category
Posts: 1
alt
Name: Command line CMD
Parent: No category
Posts: 1
alt
Name: PhpStorm
Parent: IDE
Posts: 2
alt
Name: ApiOK
Parent: Social
Posts: 1
alt
Name: Nginx
Parent: No category
Posts: 1

Posts:

Displaying 21-30 of 273 results.
Wiki: PHPStorm FIX - not working hotkey CTRL + keys functionalitywiki
posted by admin on February 27, 2017
In most java-application with a GUI on Ubuntu in Russian layout is not working hotkeys, even the standard Ctrl + C and Ctrl + V. But a good man, named Michael Zheludkov wrote fix this bug, for which he had great thanks.
Installation
Clone repository in the folder ~ / fix /:

git clone https://github.com/zheludkovm/LinuxJavaFixes.git fix

Открываем конфиг приложения: or edit with GEDIT editor

nano /opt/PhpStorm/bin/phpstorm64.vmoptions

Add the following line to the fix:

-javaagent:/home/{user}/fix/build/LinuxJavaFixes-1.0.0-SNAPSHOT.jar

Replace {user} to your Ubuntu user UsernameRead more
Wiki: Yii2 behavior and beforeSave usage example without conflicts and errorswiki
posted by admin on February 22, 2017
Behaviors:

public function behaviors()
{
return [
[
'class' => TimestampBehavior::className(),
'createdAtAttribute' => 'created_dt',
'updatedAtAttribute' => 'updated_dt',
'value' => your datetime format value,//or remove row to default with UNIX TIMESTAMP
],
];
}

BeforeSave:

public function beforeSave($insert)
{
if (parent::beforeSave($insert)) {

if ($this->isNewRecord){
//to do
}else{
//to do
}

return true;
}
return false;
}
Read more
Wiki: Yii2 beforeSave() and afterSave()wiki
posted by admin on February 22, 2017
Wonderful methods beforeSave () and afterSave () in Yii2 help us to solve various problems, for example, you want before saving the database to change the date format, or save the log action. But not everyone knows how to inherit them.

Let's start with a simple afterSave():

public function afterSave($insert, $changedAttributes){
parent::afterSave($insert, $changedAttributes);
//... to do
}

There is nothing complicated, we simply pass to the parent method all the same settings and run it, and then do everything we needed.

Now beforeSave():

public function beforeSave($insert)
{
if (parent::beforeSave($insert)) {
//... to do
return true;
}
return false;
}

All the practical as well as with afterSave() method, except that we need to return the result of the parent method, otherwise we when calling $model->save() will get false, and our model will not be saved, nor do we we will receive no errors. Remember this moment.

Yii1 The principle is the same, only the parameters are not transferred there.Read more
Resolved: Yii2 Class 'app\models\TimestampBehavior' not found
posted by admin on February 21, 2017
I have User model and have behavior in model

<?php

namespace app\models;

use Yii;
use yii\base\NotSupportedException;
use yii\db\ActiveRecord;
use yii\helpers\Security;
use yii\web\IdentityInterface;
use app\helpers\Table;
use app\helpers\App;
/**
* This is the model class for table "tbl_user".
*
* @property integer $id
* @property string $username
* @property string $password
* @property string $email
* @property integer $role_id
* @property integer $user_id
* @property integer $status_id
* @property integer $created_dt
* @property integer $updated_dt
* @property integer $timezone_id
*/
class User extends \yii\db\ActiveRecord implements IdentityInterface
{
public $authKey;
public $accessToken;

/**
* @inheritdoc
*/
public static function tableName()
{
return '{{%'.Table::$user.'}}';
}

public function behaviors()
{
return [
'timestamp' => [
'class' => TimestampBehavior::className(),
'attributes' => [
ActiveRecord::EVENT_BEFORE_INSERT => 'creation_time',
ActiveRecord::EVENT_BEFORE_UPDATE => 'update_time',
],
'value' => function() { return App::datetime_now_unix(); },
],
];
}
. . .
}

Error

Class 'app\models\TimestampBehavior' not found
Read more
Resolved: Yii2 required rule not show red star(asterisk) symbol
posted by admin on February 21, 2017
I have form and I have required fields
In output not showing red asterisk(star).
How to resolve it?Read more
Resolved: Yii2 NavBar check isGuest leave empty or fill with multiple items
posted by admin on February 21, 2017

<?php
use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use app\helpers\App;
use yii\helpers\Html;

NavBar::begin([
'brandLabel' => 'My Company',
'brandUrl' => Yii::$app->homeUrl,
'options' => [
'class' => 'navbar-inverse navbar-fixed-top',
],
]);
echo Nav::widget([
'options' => ['class' => 'navbar-nav navbar-right'],
'items' => [
['label' => App::t('Home'), 'url' => ['/site/index']],
Yii::$app->user->isGuest ? (
['label' => App::t('Login'), 'url' => ['/site/login']]
) : (
'<li>'
. Html::beginForm(['/site/logout'], 'post')
. Html::submitButton(
App::t('Logout').' (' . Yii::$app->user->identity->username . ')',
['class' => 'btn btn-link logout']
)
. Html::endForm()
. '</li>'
),
],
]);
NavBar::end();
?>

I want to add functionality like these:
1. I want to leave else empty
example

Yii::$app->user->isGuest ? (
['label' => App::t('Sign up', 'app2'), 'url' => ['/site/registration']]
) : (
[]//want to leave empty
),

2. I want multiple array
example

Yii::$app->user->isGuest ? (
['label' => App::t('Sign up0', 'app2'), 'url' => ['/site/zczczcxz']],
['label' => App::t('Sign up1', 'app2'), 'url' => ['/site/qweqweqe']],
['label' => App::t('Sign up2', 'app2'), 'url' => ['/site/asdasd']]
) : (
['label' => App::t('Sign up4', 'app2'), 'url' => ['/site/oipoiopi']],
['label' => App::t('Sign up4', 'app2'), 'url' => ['/site/oipoiopi']]
),

Both example not working and throwing errors, I think there is one decision for both situation with errorsRead more
Resolved: Yii2 The 'label' option is required NavBar
posted by admin on February 21, 2017

<?php
use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use app\helpers\App;
use yii\helpers\Html;

NavBar::begin([
'brandLabel' => 'My Company',
'brandUrl' => Yii::$app->homeUrl,
'options' => [
'class' => 'navbar-inverse navbar-fixed-top',
],
]);
echo Nav::widget([
'options' => ['class' => 'navbar-nav navbar-right'],
'items' => [
['label' => App::t('Home'), 'url' => ['/site/index']],
//['label' => 'About', 'url' => ['/site/about']],
//['label' => 'Contact', 'url' => ['/site/contact']],
Yii::$app->user->isGuest ? (
['label' => App::t('Sign up', 'app2'), 'url' => ['/site/registration']]
) : (
[]
),
Yii::$app->user->isGuest ? (
['label' => App::t('Login'), 'url' => ['/site/login']]
) : (
'<li>'
. Html::beginForm(['/site/logout'], 'post')
. Html::submitButton(
App::t('Logout').' (' . Yii::$app->user->identity->username . ')',
['class' => 'btn btn-link logout']
)
. Html::endForm()
. '</li>'
),

],
]);
NavBar::end();
?>
Read more
Resolved: LINUX How to get one database backup from all database backup file
posted by admin on February 20, 2017
I have one MySQL backup, where I have my all server database backups.
I want to get backup only for one db, for example dbname = 'mymysql'Read more
Resolved: Yii PHP DateTime UNIX TimeStamp NOW
posted by admin on February 20, 2017

$date = new DateTime();
return $date->format('U');

Error:

Class 'namespace\DateTime' not found
Read more
Resolved: Yii2 Migration multiple insert
posted by admin on February 20, 2017
I want to insert multiple rows in migration

$this->insert //insert once

I want multipleRead more