Name

QBit::Base - inheritance pattern.

it's do not working with multistate_graph

GitHub

https://github.com/QBitFramework/QBit-Base

Install

  • cpanm QBit::Base

  • apt-get install libqbit-base-perl (http://perlhub.ru/)

Example:

package MyPackage::Users;

use qbit;

use QBit::Base qw(QBit::Application::Model::DBManager::Users);

__PACKAGE_->model_fields(
    full_name => {
        label      => d_gettext('Full name'),
        depends_on => [qw(name midname surname)],
        get        => sub {
            return join(' ', grep {$_} map {$_[1]->{$_}} qw(surname name midname));
          }
    },
    phone => {
        label      => d_gettext('Phone'),
        depends_on => ['extra_fields'],
        get        => sub {
            $_[1]->{'extra_fields'}{'phone'}[0];
          }
    },
);

__PACKAGE__->model_filter(
    db_accessor => 'db',
    fields      => {
        phone => {
            type     => 'extra_fields',
            field    => 'id',
            fk_field => 'user_id',
            table    => 'users_extra_fields'
        },
    },
);

TRUE;