/** * Implements convenient method of calling static methods from * controller's model. * * @return mixed */ public function __call($method, $args) { if (preg_match('/^staticModel([a-zA-Z0-9]+)$/', $method, $m)) { $modelClass = $this->getModelClass(); $modelMethod = lcfirst($m[1]); return call_user_func_array(array($modelClass, $modelMethod), $args); } return parent::__call($method, $args); }
public function __call($method, $parameters) { if (starts_with($method, 'respond')) { $responseBuilder = new ResponseBuilder($this->format, ['only' => $this->only, 'modelName' => $this->getModelName(), 'includes' => $this->request->has('includes') ? $this->request->get('includes') : []]); return call_user_func_array([$responseBuilder, $method], $parameters); } return parent::__call($method, $parameters); }
/** * Magically handle calls to the response builder. * * @param string $method * @param array $parameters * @return mixed */ public function __call($method, $parameters) { if (method_exists($this->response, $method)) { return call_user_func_array([$this->response, $method], $parameters); } return parent::__call($method, $parameters); }