PHP code example of andmemasin / yii2-myabstract

1. Go to this page and download the library: Download andmemasin/yii2-myabstract 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/ */

    

andmemasin / yii2-myabstract example snippets


public string $userCreatedCol = 'user_created';
public string $userUpdatedCol = 'user_updated';
public string $userClosedCol = 'user_closed';
public string $timeCreatedCol = 'time_created';
public string $timeUpdatedCol = 'time_updated';
public string $timeClosedCol = 'time_closed';

return $this->hasMany(ResponseClick::class, ['response_id' => 'response_id'])
    ->using(Response::class, ['respondent_id' => 'respondent_id']);

$this->renameColumn('{{table_name}}', 'time_created', 'created_at');
$this->renameColumn('{{table_name}}', 'time_updated', 'updated_at');
$this->renameColumn('{{table_name}}', 'time_closed', 'deleted_at');
$this->renameColumn('{{table_name}}', 'user_created', 'created_by');
$this->renameColumn('{{table_name}}', 'user_updated', 'updated_by');
$this->renameColumn('{{table_name}}', 'user_closed', 'deleted_by');

$this->alterColumn('{{table_name}}', 'deleted_at', $this->dateTime(6)->null());
$this->alterColumn('{{table_name}}', 'deleted_by', $this->integer()->null());
$this->update('{{table_name}}', ['deleted_at' => null, 'deleted_by' => null], ['deleted_by' => [0, null]]);

use andmemasin\myabstract\schema\AuditSchemaHelper;

$helper = new AuditSchemaHelper(Yii::$app->db, [
    'survey',
    'sample',
]);
$helper->ensure();
bash
rg -n "time_created|time_updated|time_closed|user_created|user_updated|user_closed" modules/andmemasin/<module>