本文整理汇总了PHP中Illuminate\Routing\ResponseFactory::json方法的典型用法代码示例。如果您正苦于以下问题:PHP ResponseFactory::json方法的具体用法?PHP ResponseFactory::json怎么用?PHP ResponseFactory::json使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Routing\ResponseFactory
的用法示例。
在下文中一共展示了ResponseFactory::json方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: json
/**
* Return a new JSON response from the application.
*
* @param string|array $data
* @param int $status
* @param array $headers
* @param int $options
* @return \Illuminate\Http\JsonResponse
* @static
*/
public static function json($data = array(), $status = 200, $headers = array(), $options = 0)
{
return \Illuminate\Routing\ResponseFactory::json($data, $status, $headers, $options);
}
示例2: handle
/**
* Handle the command.
*
* @param ResponseFactory $response
*/
public function handle(ResponseFactory $response)
{
$this->builder->setFormResponse($response->json(['errors' => $this->builder->getFormErrors()->getMessages(), 'redirect' => $this->builder->getFormOption('redirect', $this->builder->getFormActions()->active()->getRedirect())]));
}
示例3: respond
/**
* Fire event and return the response
*
* @param string $event
* @param string $error
* @param integer $status
* @param array $payload
* @return mixed
*/
protected function respond($event, $error, $status, $payload = [])
{
$response = $this->events->fire($event, $payload, true);
return $response ?: $this->response->json(['error' => $error], $status);
}
示例4: search
/**
* Search for books
*
* @return \Illuminate\Http\JsonResponse
*/
public function search()
{
$books = $this->book->search($this->request->input('q'), $this->getAdvancedQueryInputs(), $this->getOptionInputs());
return $books !== false ? $this->response->json(['found' => $books]) : $this->response->json(['error' => $this->book->getErrors()], 400);
}
示例5: ajax
/**
* @param HostnameRepositoryContract $hostname
* @param ResponseFactory $response
* @return \Illuminate\Http\JsonResponse
*/
public function ajax(HostnameRepositoryContract $hostname, ResponseFactory $response)
{
return $response->json($hostname->ajaxQuery('hostname'));
}
示例6: handle
public function handle(ResponseFactory $response)
{
return $response->json($this->content, $this->status, $this->headers, $this->options);
}
示例7: handle
public function handle(ResponseFactory $factory)
{
$response = ['data' => $this->content, 'status' => $this->status];
return $factory->json($response, $this->status, $this->headers, $this->options);
}
示例8: respond
/**
* Fire event and return the response
*
* @param string $event
* @param string $error
* @param integer $status
* @param array $payload
* @return mixed
*/
protected function respond($event, $error, $status, $payload = [])
{
$response = $this->events->fire($event, $payload, true);
return $response ?: $this->response->json(arrayView('phpsoft.users::errors/authenticate', ['error' => $error]), $status);
}
示例9: search
/**
* Search for the vacancies
*
* @return \Illuminate\Http\JsonResponse
*/
public function search()
{
$data = $this->vacancy->search($this->request->input('q'), $this->getOptionInputs());
return $this->response->json(['vacancies' => $data]);
}
示例10: handle
public function handle(Larasponse $larasponse, ResponseFactory $response)
{
$item = $larasponse->item($this->data, $this->transformer);
return $response->json($item, $this->status, $this->headers, $this->options);
}