fuel / orm

Fuel PHP Framework - Fuel v1.x ORM
http://fuelphp.com/docs/packages/orm/intro.html
152 stars 96 forks source link

Enhancement: table views in related models #424

Open Oggo87 opened 5 years ago

Oggo87 commented 5 years ago

Right now, when relating models, there's no way of using a specific table view for the related model. It would be a nice feature to be able to do something as the following:

$query = Glazes\Model_Colour::query()
    ->related('formulas')
    ->use_view('formulas.glaze_formulas_table_view');

Or even to define a default view for the relation:

protected static $_has_many = array(
        'formulas' => array(
            'key_from'       => 'id',
            'model_to'       => 'Glazes\Model_Formula',
            'key_to'         => 'colour_id',
            'view'         => 'glaze_formulas_table_view',
            'cascade_save'   => false,
            'cascade_delete' => false,
            'conditions'     => array(
                    'order_by' => array('date' => 'desc')
            )
    )
);