/** * Controller constructor. * @param $module * @param $entity */ public function __construct($module, $entity) { $this->module = Parse::camelize($module, true); $this->entity = Parse::camelize($entity, true); $path = Path::name($this->module, $this->entity); $this->model = new $path(); }
/** * * @param type $item * @return type */ public function relationshipDefaultModel($item) { $relationship = $item->relationship; $related = Path::name($relationship->module, $relationship->entity); $type = $relationship->type; switch ($type) { case 'one-to-one': return $this->hasOne($related, $relationship->key); case 'one-to-many': return $this->hasMany($related, $relationship->key, $relationship->local); default: break; } }