Open crustamet opened 5 years ago
I will be running this this evening to see if I can diagnose the issue!
thanks i found some problems with the BaseModel that is extending made some debug stuff.
`public function findAll(int $limit = 0, int $offset = 0) { $this->applyScopes();
$models = parent::findAll($limit, $offset);
// If models returned, eager load relations
if (count($models) > 0) {
$models = $this->eagerLoadRelations([$this]);
}
// Return new collection of models
return $models;
}`
this code when you getting the "$models" $models = parent::findAll($limit, $offset);
this does not returns the MODELS it is just returning the ITEMS from the TABLE
From here is passing to all other files THE ITEMS and not the MODELS
I dont know how this baseModel worked for you but you clearly have something else..
I got a error like this Attempt to read property \"id\" on array
`<?php namespace App\Models\Frontpanel;
use App\Models\BaseModel;
class Menu extends BaseModel { protected $table = 'frontpanel_menus'; protected $primaryKey = 'id_menu'; protected $foreignKey = 'id_connector';
}
class Connectors extends BaseModel { protected $table = 'frontpanel_connectors'; protected $foreignKey = 'id_menu'; protected $primaryKey = 'id_connector';
} `
inside Controller
$menu = new Menu(); print_r($menu->find(10)->connectors); die();
i get ERROR : Undefined property: stdClass::$connectors
BTW
BASEMODEL line 561 i modified this method
public function getForeignKey() { return $this->foreignKey; }
it has no sense to hardcode it, so i changed so it would work with appended ids also id_menu, id_connector, ETC...