<?php


namespace app\em\model;


class EmAccount extends Base
{
    protected $table  = 'em_account';

    public function getIdByInvoiceID($inv_id){
        $data =  self::alias('ea')
                     ->leftJoin(['em'],'em.id=ea.em_id')
                     ->leftJoin(['em_useage'=>'eu'],'eu.em_id = em.id')
                     ->leftJoin(['em_invoice_useage'=>'eiu'],'eiu.useage_id=eu.useage_id')
                     ->where('eiu.invoice_id','=',$inv_id)
                     ->find();
        return $data;
    }
}