ActiveRecord PHP relationship

1

I have two tables, requests and middle_payments in the pedidos table I have the foreign key meio_pagamento_id , as I define their relationship through of activerecord php?

I tried :

ClassPay Payment

class MeioPagamento extends ActiveRecord\Model{
    static $table_name = 'meio_pagamento';
    static $has_many = array(
        array('pedido', 'class_name' => 'Pedido', 'foreign_key' => 'meio_pagamento_id')        
    );
}

Order Class

class Pedido extends ActiveRecord\Model{
    static $belongs_to = array(
        array('pagamento'),
        array('empresa'),
        array('meio_pagamento', 'class_name' => 'MeioPagamento', 'foreign_key' => 'meio_pagamento_id')
    );

    static $has_many = array(
        array(
            'itens', 
            'class_name' => 'Item', 
            'foreign_key' => 'pedido_id', 
            'primary_key' => 'id'
        )
    );
}
    
asked by anonymous 19.08.2015 / 22:11

0 answers