/** * Itterate over object, build a relations, fillable and includes collection. * * @param model $object the model to iterate over * * @return array */ private function includes($object) { $fillable = $object->getFillable(); $includes = $object->getIncludes(); $table = $object->getTable(); $columns = $object->columns(); $results[$table] = []; if (!empty($includes)) { foreach ($includes as $include) { $results[$table] = ['object' => $object, 'includes' => $this->includes(new $include())]; } } $this->fillables->put($table, $fillable); $this->includes->push($table, $table); $this->columns->put($table, $columns); return $results; }