PHP code example of andreykluev / yii2-crud-actions
1. Go to this page and download the library: Download andreykluev/yii2-crud-actions library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
andreykluev / yii2-crud-actions example snippets
php
use andreykluev\crudactions\crudActionCreate;
use andreykluev\crudactions\crudActionDelete;
use andreykluev\crudactions\crudActionUpdate;
use common\models\Product;
class CatalogController extends AppController
{
...
public function actions()
{
return array(
'insert' => [
'class' => crudActionCreate::className(),
'model' => new Product(),
'view' => 'update-album',
'onBeforeAction' => [$this, 'beforeSaveProduct'],
'onAfterAction' => [$this, 'afterSaveProduct'],
],
'update' => [
'class' => crudActionUpdate::className(),
'modelClass' => Product::className(),
'attributes' => [
'id_user' => Yii::$app->user->identity->getId(),
'id_album' => Yii::$app->request->get('idAlbum', 0),
],
'view' => 'update-album',
'onBeforeAction' => [$this, 'beforeSaveProduct'],
'onAfterAction' => [$this, 'afterSaveProduct'],
],
'delete' => [
'class' => crudActionDelete::className(),
'modelClass' => Product::className(),
'onBeforeAction' => [$this, 'beforeDeleteProduct'],
'onAfterAction' => [$this, 'afterDeleteProduct'],
],
...
);
}
...
public function beforeSaveProduct()
{
// Ваш код
}
public function afterSaveProduct($isSave = false)
{
// Ваш код
}
public function beforeDeleteProduct()
{
// Ваш код
}
public function afterDeleteProduct($isDelete = false)
{
// Ваш код
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.