To do this, we need the following:
/* ... */ use Yii; use yiirbacItem; /* ... */ $auth = Yii::$app -> authManager; $Item = new Item(); $Item -> type = 3; $Item -> name = 'ItemNewName' $Item -> description = 'ItemNewDescription'; $auth -> add($Item);
Order website or plugin development for WordPress, website development on the Laravel, Symfony, or Yii2 framework…

To do this, we need the following:
/* ... */ use Yii; use yiirbacItem; /* ... */ $auth = Yii::$app -> authManager; $Item = new Item(); $Item -> type = 3; $Item -> name = 'ItemNewName' $Item -> description = 'ItemNewDescription'; $auth -> add($Item);

The first thing we need to do is include "Pjax" itself:
use yiiwidgetsPjax;
Next, wrap the desired content in the Pjax widget. For example:
<?php Pjax::begin([ 'id' => 'pjaxContent' ]); ?> Content here <?php Pjax::end(); ?>

There’s a saying:
live and learn — and still die a fool
Why am I saying this? It’s about traits in PHP. They’ve been around for quite a while, but I only recently started using them in a new project.
The first thing I had to do was move the attributeLabels method into a trait. Yes, I could have created a single base class and extended it. But I decided to go with traits instead. So, here’s what we have:
namespace commontraitsobject;
use Yii;
trait ObjectModelTrait
{
/**
* Labels
* @return array
*/
public function attributeLabels()
{
return [
'id' => Yii::t('app', 'ID'),
'name' => Yii::t('app', 'Name'),
'desc' => Yii::t('app', 'Description'),
'index_id' => Yii::t('app', 'Index'),
'is_active' => Yii::t('app', 'Is active'),
];
}
}This trait was reused multiple times in models. Here’s one example:
namespace commonmodelsterritory;
use yiidbActiveRecord;
use commontraitsobjectObjectModelTrait;
class TerritoryAreaModel extends ActiveRecord
{
use ObjectModelTrait;
public static function tableName()
{
return '{{%territory_area}}';
}
}
Validation can be disabled both on the client side (for yiiActiveForm) and on the server side.
Using a scenario will indicate that server-side validation should be skipped for certain fields.
On the client side, validation for specific fields will be dynamically removed depending on the selected action (in our case — delete).
Our controller:
$NewsletterMailForm = new NewsletterMailForm();
if(Yii::$app -> request -> post($NewsletterMailForm -> formName())['event'] != NewsletterMailForm::EVENT_DELETE)
{
$NewsletterMailForm -> scenario = NewsletterMailForm::EVENT_SEND;
}If the "event" field is not equal to "delete", it means we are going to send emails (no other actions are handled at this point).

To do this, you should form the query as follows:
Yii::$app -> db -> createCommand() -> update(ContactusModel::tableName(), ['is_read' => 0], [ 'id' => $this -> id ]) -> execute();
Where:
ContactusModel::tableName() — the target table
$this -> id — an array of IDs, which will automatically generate a query with IN (.., .., .....)