/** * function setModel($model): * This method will set the model array as an object within MatchaCUP scope * * @param $model * * @return bool|\MatchaCUP */ public function setModel($model) { $this->model = is_array($model) ? MatchaUtils::__arrayToObject($model) : $model; if (isset($this->model->table)) { if (is_string($this->model->table)) { $this->table = $this->model->table; } else { $this->table = $this->model->table->name; } } else { $this->table = false; } $this->date = new DateTime(); $this->primaryKey = MatchaModel::__getTablePrimaryKeyColumnName($this->table); $this->fields = MatchaModel::__getFields($this->model); $this->encryptedFields = MatchaModel::__getEncryptedFields($this->model); $this->phantomFields = MatchaModel::__getPhantomFields($this->model); $this->arrayFields = MatchaModel::__getArrayFields($this->model); $this->hasMany = isset($model['hasMany']) ? $model['hasMany'] : []; $this->hasOne = isset($model['hasOne']) ? $model['hasOne'] : []; }