CakePHP 3.0: Get model data from two degree model of separation in pagination -


now i'm tired can't think well. sorry anticipated if duplicate question , if english weird.

in cakephp 3.0 have model "asistencias". asosiated "ejecutivos". so, in asistencias table, have de fk ejecutivo_id , works ok when try access data ejecutivos table because made correct declaration:

$this->paginate = [             //'contain' => ['sucursales', 'cedentes', 'ejecutivos'],             'contain' => ['ejecutivos'],             'limit'=>100,             'order'=>['asistencias.entrada'=>'desc', 'ejecutivos.nombre'=>'desc']                    ]; 

as can see, i've commented line 2. take out asosiation of cedentes , sucursales asistencias.

now, fks sucursal_id , cedente_id belongs ejecutivos table, instead asistencias table. it's me make others tasks in cakephp doesn't interest you.

my question how can access sucursales , cedentes in efficient way? guess can't call them contain in paginate properties.

i want use them in view this:

//index.ctp foreach($asistencias $asistencia){   echo $asistencia->ejecutivos->name;   echo $asistencia->ejecutivos->sucursal->name;   echo $asistencia->ingreso;   echo $asistencia->salida; } 

i can't remember correct way. can me?

you can nest contains desired result.

$this->paginate = [         'contain' => [               'ejecutivos' => [                      'sucursales', 'cedentes',                 ],         ],         'limit'=>100,         'order'=>['asistencias.entrada'=>'desc', 'ejecutivos.nombre'=>'desc']                ]; 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -