Idea: Active Record attribute structure

Hi
It is good to have a method that contains the schema of the model.
Based on this method, it is easy to create migration, connect to different types of databases(such as Mysql, mongoDb or …) and have hierarchical structure in the model.
for example :
Instead of ‘attributeLabels’ and ‘rules’ methods, we have the following method in ActiveRecord or Model class:

public function attributes()
{
    return [
        'id' => [
            'label' => 'ID',
            'type' => 'bigIncrement',
            'default' => null,
        ],
        'user_id' => [
            'label' => 'User ID',
            'type' => 'bigint',
            //We can mention relationships here or not
        ],
        'title' => [
            'label' => 'Title',
            'type' => 'text',
            'rules' => ['min' => 5, 'max' => 48, 'required' => true],
            'default' => '',
        ],
        'customer_code' => [
            'label' => 'Customer Code',
            'type' => 'int',
            'rules' => function ($value) {
                return preg_match('/anything/', $value);
            },
        ],
        'metadata' => [
            'type' => 'json',
            'structure' => [
                'author_name' => [
                    'label' => 'author name',
                    'type' => 'text',
                ],
                'author_family' => [
                    'label' => 'author family',
                    'type' => 'text',
                ],
                'author_gender' => [
                    'label' => 'author gender',
                    'type' => 'text',// or enum
                    'option' => [
                        'u' => 'Unknown',
                        'm' => 'Man',
                        'w' => 'Woman',
                    ],
                ],
            ],
        ],
        'status' => [
            'label' => 'Status',
            'type' => 'int',// or enum
            'option' => [
                0 => 'Draft',
                1 => 'Pending',
                2 => 'Accepted',
            ],
        ],
        'created_at' => 'createTimestamp',//using template
        'updated_at' => 'updateTimestamp',//using template
    ];
}

With this method, the problem of matching different databases will be largely solved, and we can handle the CRUD with a general methods based on this schema.

That’s how it works now except this schema is fetched from database. See https://www.yiiframework.com/doc/api/2.0/yii-db-activerecord#getTableSchema()-detail

In my plan, the reference is method, not database.
Of course For the first time(in Gii), this method can be extracted from the database.

for tricky, temporary we can create Helper for extract attributs

i.e

public function attributes() 
{
   return [...];
}

public function rules()
{
    return ModelHelper::getRules($this->attributes());
}

public function attributeLabels() 
{
    return ModelHelper::getAttributeLabels($this->attributes());
}

To reduce the dependence on the database structure (and of course better support for micro-service), I think the repository pattern is a better choice:

https://webdevetc.com/blog/the-repository-pattern-in-php-and-laravel