protected function response(Response $response) { foreach ($response->headers->all() as $name => $values) { $name = str_replace(' ', '-', ucwords(str_replace('-', ' ', $name))); foreach ($values as $value) { header($name . ': ' . $value, false, $response->statusCode); } } echo $response->content(); }
protected function response(Response $response) { foreach ($response->headers->all() as $name => $values) { $name = str_replace(' ', '-', ucwords(str_replace('-', ' ', $name))); foreach ($values as $value) { header($name . ': ' . $value, false, $response->statusCode); } } foreach ($response->cookies as $cookie) { setcookie($cookie->name, $cookie->value, $cookie->expire, $cookie->path, $cookie->domain, $cookie->secure, $cookie->httpOnly); } echo $response->content(); }
public function store(Request $request, Response $response) { $rules = ['name' => 'required']; $validator = app('validation')->make($request->all(), $rules); if ($validator->fails()) { $request->session->add(['errors' => $validator->errors()->all()]); return app('twig')->render('pads/create.htm'); } $pad = new Pad(); $pad->name = $request->input('name'); $pad->user_id = $request->user()->id; $pad->save(); $request->session->add(['success' => 'Pad saved successfuly.']); return $response->redirect("/pads/{$pad->id}/update"); }
/** * Returns the response as json. * * @return mixed */ public function asJson() { if (!$this->isJsonMessage($this->response->headers)) { throw new \RuntimeException('The response is not a valid json response'); } return json_decode($this->response->content(), true); }
public function delete($id, Request $request, Response $response, Note $noteModel) { $note = $this->noteExists($id); if (!$note) { return $response->redirect('/notes'); } $note->delete(); $request->session->add(['success' => 'Note deleted successfuly.']); return $response->redirect('/notes'); }
public function compute($a, $b, Response $response) { $response->with($a * $b); return $response; }
public function logout(Request $request, Response $response) { auth()->logout($request->session->id); return $response->redirect('/signin'); }