Inheritance: extends blink\core\Object, implements blink\core\ShouldBeRefreshed, use trait blink\core\MiddlewareTrait
示例#1
0
 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();
 }
示例#2
0
 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();
 }
示例#3
0
 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");
 }
示例#4
0
 /**
  * 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);
 }
示例#5
0
 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');
 }
示例#6
0
 public function compute($a, $b, Response $response)
 {
     $response->with($a * $b);
     return $response;
 }
示例#7
0
 public function logout(Request $request, Response $response)
 {
     auth()->logout($request->session->id);
     return $response->redirect('/signin');
 }