With cakephp i'm making a simple slideshow.
In my PagesController i write the home action as follows:
public function home(){
// slider
$this->loadModel('CmsStoreSlider');
$cmsStoreSlider = $this->CmsStoreSlider->find('all')->toArray();
$this->set(compact('cmsStoreSlider'));
$this->set('_serialize', ['cmsStoreSlider']);
}
... and in my Pages/home.ctp i try to call $cmsStoreSlider, but without luck.
<?php foreach ($cmsStoreSlider as $cmsStoreSlider): ?>
<img src="<?= $cmsStoreSlider->image; ?>" alt="Imagem do slider">
<?php endforeach; ?>
The images are not displaying because cakephp says it invalid argument supllied for foreach. I made a var_dump and says $cmsStoreSlider is an undefined variable.
Any Solutions. i'm new to cake and maybe something is missing in my logic.
Ps. The Entity and table model are created.