当前位置: 首页>>代码示例>>PHP>>正文


PHP Http\Response类代码示例

本文整理汇总了PHP中Illuminate\Http\Response的典型用法代码示例。如果您正苦于以下问题:PHP Response类的具体用法?PHP Response怎么用?PHP Response使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Response类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getQr

 public function getQr(Request $req)
 {
     $qrCode = new QrCode();
     $qrCode->setText("http://10.0.20.55:8001/index/wel#/sys/activities/one")->setSize(300)->setPadding(10)->setErrorCorrection('high')->setForegroundColor(array('r' => 0, 'g' => 0, 'b' => 0, 'a' => 0))->setBackgroundColor(array('r' => 255, 'g' => 255, 'b' => 255, 'a' => 0));
     $response = new Response($qrCode->get(), 200);
     $response->header('content-type', 'image/png');
     return $response;
 }
开发者ID:vimac,项目名称:hackathon2015,代码行数:8,代码来源:CommonController.php

示例2: getIndex

 public function getIndex(Request $request)
 {
     $data = [];
     $userControllerObj = new UserController();
     $cookie = $userControllerObj->checkCookie($request);
     $data['categories'] = Categories::getCategories();
     if ($cookie === 0) {
         return View::make('index', $data);
     } else {
         if ($cookie === -1) {
             $response = new Response('Your cookie is invalid, We have cleared it for you, Refresh to re-login to NEUP-Channel');
             return $response->withCookie('neupchan', "", -1);
         } else {
             if ($cookie->shortCookie === NULL) {
                 $shortCookie = $cookie->short_cookie;
                 $data['firstLogin'] = true;
             } else {
                 $shortCookie = $cookie->shortCookie;
                 $data['lastLoginIP'] = $cookie->last_login_ip;
             }
         }
     }
     $data['shortCookie'] = $shortCookie;
     //return View::make('index', $data)->withCookie(cookie('neupchan', $cookie, 90 * 24 * 60));
     $response = new Response(view('index', $data));
     if (isset($data['firstLogin'])) {
         return $response->withCookie('neupchan', $cookie, 90 * 24 * 60);
     } else {
         return $response;
     }
 }
开发者ID:VOID001,项目名称:NEUP-channel,代码行数:31,代码来源:ContentController.php

示例3: makeMessageFromResponse

 protected function makeMessageFromResponse(Response $response)
 {
     $message['original_content'] = $response->getOriginalContent();
     $message['content'] = $response->getContent();
     $message['status_code'] = $response->getStatusCode();
     return json_encode($message, JSON_PRETTY_PRINT);
 }
开发者ID:alfred-nutile-inc,项目名称:incomings-client,代码行数:7,代码来源:IncomingsMiddleWare.php

示例4: handle

 public function handle($request, Closure $next)
 {
     $response = new Response();
     if (Auth::check() === false) {
         $request->request->set('roleId', $this->retrieveRoleIdByName('Customer'));
         return $next($request);
     }
     $user = Auth::user();
     if ($user === null) {
         $response->header(Constants::RESPONSE_HEADER, "Failed to retrieve authenticated user.");
         $response->setStatusCode(Response::HTTP_INTERNAL_SERVER_ERROR);
         return $response;
     }
     $role = Roles::where('id', $user->role_id)->firstOrFail();
     if ($role->name !== "Administrator") {
         $response->header(Constants::RESPONSE_HEADER, "Permission are required for performing registration operation.");
         $response->setStatusCode(Response::HTTP_FORBIDDEN);
         return $response;
     }
     try {
         $roleName = $request->get('roleName');
         if ($roleName === null) {
             $request->request->set('roleId', $this->retrieveRoleIdByName('Customer'));
         } else {
             $request->request->set('roleId', $this->retrieveRoleIdByName($roleName));
         }
     } catch (Exception $exception) {
         $response->header(Constants::RESPONSE_HEADER, $exception->getMessage());
         $response->setStatusCode(Response::HTTP_BAD_REQUEST);
         return $response;
     }
     return $next($request);
 }
开发者ID:JulietaGosheva,项目名称:truck-shop,代码行数:33,代码来源:RegistrationMiddleware.php

示例5: setResponse

 /**
  * Preparing Response
  *
  * @return Response
  */
 protected function setResponse()
 {
     $response = new Response();
     $response->setStatusCode($this->content['http_code']);
     $response->setContent($this->content);
     return $response;
 }
开发者ID:Baasify,项目名称:Baasify,代码行数:12,代码来源:MainController.php

示例6: deleteMemberFund

 /**
  * Deletes members funds and recalculates total
  *
  * @param $incomeServiceId
  * @param $memberId
  * @return \Illuminate\Http\JsonResponse
  */
 public function deleteMemberFund($incomeServiceId, $memberId, Response $response, Gate $gate)
 {
     if (!$gate->check('putPostDelete', new IncomeServiceMemberFund())) {
         return $response->setContent('Unauthorized')->setStatusCode(401);
     }
     return response()->json($this->dispatch(new DeleteIncomeServiceMemberFundTotal($incomeServiceId, $memberId)));
 }
开发者ID:jraymundoyrockdev,项目名称:api-gfccm-systems,代码行数:14,代码来源:IncomeServiceMemberFundsController.php

示例7: responseFactory

 public function responseFactory($content, $code = 200)
 {
     $response = new Response();
     $response->setContent($content);
     $response->setStatusCode($code);
     return $response;
 }
开发者ID:helpscout,项目名称:specter,代码行数:7,代码来源:IlluminateHttpFactory.php

示例8: postRegister

 public function postRegister(Request $request)
 {
     $errors = [];
     // Validate all fields have been received.
     $validator = \Validator::make($request->all(), array('email' => 'required|email|max:128|unique:users,email', 'username' => 'required|min:1|max:20|unique:users,name', 'password' => 'required|min:6|max:255', 'g-recaptcha-response' => 'recaptcha'));
     if ($validator->fails()) {
         // Validator detected some problems.
         foreach ($validator->errors()->getMessages() as $error) {
             $errors[] = $error;
         }
     }
     if (count($errors) > 0) {
         // Errors detected, generate response
         $response = new Response(json_encode(['status' => false, 'errors' => $errors]), 200);
         $response->header('Content-Type', 'application/json');
         return $response;
     }
     // Get input
     $email = $request->input('email');
     $username = $request->input('username');
     $password = $request->input('password');
     // Register user
     $user = User::register($email, $username, $password);
     // Login
     Auth::login($user);
     // Generate response
     $response = new Response(json_encode(['status' => true]), 200);
     $response->header('Content-Type', 'application/json');
     return $response;
 }
开发者ID:harmjanhaisma,项目名称:clearboard,代码行数:30,代码来源:LoginController.php

示例9: addRateLimitToResponse

 /**
  * Add the RateLimit to the response cookies.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Illuminate\Http\Response $response
  * @return \Illuminate\Http\Response
  */
 protected function addRateLimitToResponse($request, $response, $limit)
 {
     $throttle = $this->throttle->get($request);
     $response->header('x-rate-limit-limit', $limit);
     $response->header('x-rate-limit-remaining', $limit - $throttle->count());
     return $response;
 }
开发者ID:sonoftheweb,项目名称:laravel-angular-cms,代码行数:14,代码来源:ThrottleMiddleware.php

示例10: put

 public function put(Route $route, Request $request, Response $response)
 {
     $key = $this->makeCacheKey($request->url());
     if (!Cache::has($key)) {
         Cache::put($key, $response->getContent(), 10);
     }
 }
开发者ID:RichJones22,项目名称:TimeTrax,代码行数:7,代码来源:CacheFilters.php

示例11: serialize

 /**
  * Serialize a response.
  *
  * @param \Illuminate\Http\Response $response
  *
  * @return string
  */
 public function serialize(Response $response)
 {
     $content = $response->getContent();
     $statusCode = $response->getStatusCode();
     $headers = $response->headers;
     return serialize(compact('content', 'statusCode', 'headers'));
 }
开发者ID:sdebacker,项目名称:laravel-responsecache,代码行数:14,代码来源:ResponseSerializer.php

示例12: store

 /**
  * Create new Income Service
  *
  * @param IncomeServiceRequest $request
  * @param Guard $guard
  * @param Response $response
  * @param Gate $gate
  * @return ItemResponse|\Symfony\Component\HttpFoundation\Response
  */
 public function store(IncomeServiceRequest $request, Guard $guard, Response $response, Gate $gate)
 {
     if (!$gate->check('putPostDelete', new IncomeService())) {
         return $response->setContent('Unauthorized')->setStatusCode(401);
     }
     return new ItemResponse($this->dispatch(new CreateIncomeServiceCommand($request->get('service_id'), $request->get('service_date'), $guard->user()->id, 3, 'status')));
 }
开发者ID:jraymundoyrockdev,项目名称:api-gfccm-systems,代码行数:16,代码来源:IncomeServicesController.php

示例13: addCookieConsentScriptToResponse

 /**
  * @param \Illuminate\Http\Response $response
  *
  * @return $this
  */
 protected function addCookieConsentScriptToResponse(Response $response)
 {
     $content = $response->getContent();
     $closingBodyTagPosition = $this->getLastClosingBodyTagPosition($content);
     $content = '' . substr($content, 0, $closingBodyTagPosition) . view('cookieConsent::index')->render() . substr($content, $closingBodyTagPosition);
     return $response->setContent($content);
 }
开发者ID:spatie,项目名称:laravel-cookie-consent,代码行数:12,代码来源:CookieConsentMiddleware.php

示例14: appendDisqusScript

    /**
     * Append disqus script on the end of the page.
     *
     * @param  \Illuminate\Http\Request $request
     * @param  \Illuminate\Http\Response $response
     * @return mixed
     */
    protected function appendDisqusScript($request, $response)
    {
        $content = $response->getContent();
        if (!Str::contains($content, '<div id="disqus_thread"></div>')) {
            return;
        }
        $uri = $request->getRequestUri();
        $pageUrl = url($uri);
        $pageId = 'route' . implode('.', explode('/', $uri));
        $username = config('disqus.username');
        $disqusHtml = <<<CDATA
<script>
     var disqus_config = function () {
         this.page.url = '{$pageUrl}';
         this.page.identifier = '{$pageId}';
     };

    (function() {  // DON'T EDIT BELOW THIS LINE
        var d = document, s = d.createElement('script');

        s.src = '//{$username}.disqus.com/embed.js';

        s.setAttribute('data-timestamp', +new Date());
        (d.head || d.body).appendChild(s);
    })();
</script>
<noscript>Please enable JavaScript to view the <a href=\\"https://disqus.com/?ref_noscript\\" rel=\\"nofollow\\">comments powered by Disqus.</a></noscript>
CDATA;
        $bodyPosition = strripos($content, '</body>');
        if (false !== $bodyPosition) {
            $content = substr($content, 0, $bodyPosition) . $disqusHtml . substr($content, $bodyPosition);
        }
        $response->setContent($content);
    }
开发者ID:yajra,项目名称:laravel-disqus,代码行数:41,代码来源:DisqusMiddleware.php

示例15: store

 public function store()
 {
     $preferences = Request::all();
     $response = new Response('OK');
     $response->withCookie(Cookie::forever(PreferencesVO::PREFERENCES_AMOUNT, $preferences['amount'], PreferencesVO::PREFERENCES_LIFESPAN))->withCookie(Cookie::forever(PreferencesVO::PREFERENCES_PERIOD, $preferences['period'], PreferencesVO::PREFERENCES_LIFESPAN))->withCookie(Cookie::forever(PreferencesVO::PREFERENCES_TAXCDB, $preferences['taxcdb'], PreferencesVO::PREFERENCES_LIFESPAN))->withCookie(Cookie::forever(PreferencesVO::PREFERENCES_TAXLCI, $preferences['taxlci'], PreferencesVO::PREFERENCES_LIFESPAN));
     return $response;
 }
开发者ID:nielsonsantana,项目名称:rendafixa,代码行数:7,代码来源:PreferencesController.php


注:本文中的Illuminate\Http\Response类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。