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


PHP Facades\Response类代码示例

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


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

示例1: put

 public function put(Route $route, Request $request, Response $response)
 {
     $key = $this->makeCacheKey($request->url());
     if (!Cache::has($key)) {
         Cache::put($key, $response->getContent(), 60);
     }
 }
开发者ID:DinanathThakur,项目名称:Flash-Sale-Ecommerce-Portal-PHP,代码行数:7,代码来源:CacheFilter.php

示例2: delete

 public function delete()
 {
     $id = Input::get('id');
     $this->model = Terrain::find($id);
     $this->model->delete();
     return Response::json(['success' => true]);
 }
开发者ID:binaryk,项目名称:pedia,代码行数:7,代码来源:PreTerrainController.php

示例3: destroy

 /**
  * Removes a target server from a rule.
  * @param string $id The rule ID and md5 hash of the target address seperated by the
  * hyphen '-' character eg. 2-23a23e5605cc132c95b4902b7b3c0072 in the example, '2' is the
  * ID of the rule to remove the MD5 representation of the target name eg. md5('172.23.32.2')
  * @return Repsonse
  */
 public function destroy($id)
 {
     $idhash = explode('-', $id);
     $id = $idhash[0];
     // The ID of the rule which the target is to be removed from.
     $hash = $idhash[1];
     // The MD5 representation of the target address.
     $rule = Rule::find($id);
     if ($rule) {
         $config = new NginxConfig();
         $config->setHostheaders($rule->hostheader);
         $config->readConfig(Setting::getSetting('nginxconfpath') . '/' . $config->serverNameToFileName() . '.enabled.conf');
         $existing_targets = json_decode($config->writeConfig()->toJSON());
         // We now iterate over each of the servers in the config file until we match the 'servers' name with the hash and when we do
         // we delete the host from the configuration file before writing the chagnes to disk...
         $deleted = false;
         foreach ($existing_targets->nlb_servers as $target) {
             if (md5($target->target) == $hash) {
                 // Matches the target hash, we will now remove from the config file and break out the foreach.
                 $config->removeServerFromNLB($target->target);
                 $deleted = true;
                 break;
             }
         }
         $config->writeConfig()->toFile(Setting::getSetting('nginxconfpath') . '/' . $config->serverNameToFileName() . '.enabled.conf');
         $config->reloadConfig();
         if ($deleted) {
             return Response::json(array('errors' => false, 'message' => 'The target was successfully remove from the rule.'), 200);
         } else {
             return Response::json(array('errors' => true, 'message' => 'The target server was not found in the configuration.'), 404);
         }
     } else {
         return Response::json(array('errors' => true, 'message' => 'The target parent rule was not found and therefore could not be removed.'), 404);
     }
 }
开发者ID:Thomvh,项目名称:turbine,代码行数:42,代码来源:TargetController.php

示例4: markAcceptance

 public function markAcceptance($policyCode, $userUid)
 {
     // get inputs
     //
     $policy = Policy::where('policy_code', '=', $policyCode)->first();
     $user = User::getIndex($userUid);
     $acceptFlag = Input::has('accept_flag');
     // check inputs
     //
     if (!$user || !$policy || !$acceptFlag) {
         return Response::make('Invalid input.', 404);
     }
     // check privileges
     //
     if (!$user->isAdmin() && $user->user_uid != Session::get('user_uid')) {
         return Response::make('Insufficient privileges to mark policy acceptance.', 401);
     }
     // get or create new user policy
     //
     $userPolicy = UserPolicy::where('user_uid', '=', $userUid)->where('policy_code', '=', $policyCode)->first();
     if (!$userPolicy) {
         $userPolicy = new UserPolicy(array('user_policy_uid' => GUID::create(), 'user_uid' => $userUid, 'policy_code' => $policyCode));
     }
     $userPolicy->accept_flag = $acceptFlag;
     $userPolicy->save();
     return $userPolicy;
 }
开发者ID:pombredanne,项目名称:open-swamp,代码行数:27,代码来源:UserPoliciesController.php

示例5: respondWithArray

 protected function respondWithArray(array $array, array $headers = [])
 {
     $mimeTypeRaw = Input::server('HTTP_ACCEPT', '*/*');
     // If its empty or has */* then default to JSON
     if ($mimeTypeRaw === '*/*') {
         $mimeType = 'application/json';
     } else {
         // You'll probably want to do something intelligent with charset if provided
         // This chapter just assumes UTF8 everything everywhere
         $mimeParts = (array) explode(',', $mimeTypeRaw);
         $mimeType = strtolower($mimeParts[0]);
     }
     switch ($mimeType) {
         case 'application/json':
             $contentType = 'application/json';
             $content = json_encode($array);
             break;
         case 'application/x-yaml':
             $contentType = 'application/x-yaml';
             $dumper = new YamlDumper();
             $content = $dumper->dump($array, 2);
             break;
         default:
             $contentType = 'application/json';
             $content = json_encode(['error' => ['code' => static::CODE_INVALID_MIME_TYPE, 'http_code' => 415, 'message' => sprintf('Content of type %s is not supported.', $mimeType)]]);
     }
     $response = Response::make($content, $this->statusCode, $headers);
     $response->header('Content-Type', $contentType);
     return $response;
 }
开发者ID:kife-design,项目名称:knoters,代码行数:30,代码来源:ApiController.php

示例6: sendLockoutResponse

 protected function sendLockoutResponse(Request $request)
 {
     if ($request->ajax()) {
         return Response::make("Too Many Requests", 429);
     }
     return $this->traitSendLockoutResponse($request);
 }
开发者ID:MetropoliaUAS,项目名称:ISDProject-Online,代码行数:7,代码来源:AuthController.php

示例7: destroy

 public function destroy()
 {
     $conferenceId = Input::get('conferenceId');
     $talkRevisionId = Input::get('talkRevisionId');
     $this->dispatch(new DestroySubmission($conferenceId, $talkRevisionId));
     return Response::json(['status' => 'success', 'message' => 'Talk Un-Submitted']);
 }
开发者ID:elazar,项目名称:symposium,代码行数:7,代码来源:SubmissionsController.php

示例8: getIndex

 public function getIndex($type, $id)
 {
     $column = '';
     if ($type == 'track') {
         $column = 'track_id';
     } else {
         if ($type == 'user') {
             $column = 'profile_id';
         } else {
             if ($type == 'album') {
                 $column = 'album_id';
             } else {
                 if ($type == 'playlist') {
                     $column = 'playlist_id';
                 } else {
                     App::abort(500);
                 }
             }
         }
     }
     $query = Comment::where($column, '=', $id)->orderBy('created_at', 'desc')->with('user');
     $comments = [];
     foreach ($query->get() as $comment) {
         $comments[] = Comment::mapPublic($comment);
     }
     return Response::json(['list' => $comments, 'count' => count($comments)]);
 }
开发者ID:nsystem1,项目名称:Pony.fm,代码行数:27,代码来源:CommentsController.php

示例9: postCreate

 public function postCreate()
 {
     // create a single model
     //
     $projectInvitation = new ProjectInvitation(array('project_uid' => Input::get('project_uid'), 'invitation_key' => GUID::create(), 'inviter_uid' => Input::get('inviter_uid'), 'invitee_name' => Input::get('invitee_name'), 'email' => Input::get('email')));
     $user = User::getByEmail(Input::get('email'));
     if ($user) {
         if (ProjectMembership::where('user_uid', '=', $user->user_uid)->where('project_uid', '=', Input::get('project_uid'))->where('delete_date', '=', null)->first()) {
             return Response::json(array('error' => array('message' => Input::get('invitee_name') . ' is already a member')), 409);
         }
     }
     $invite = ProjectInvitation::where('project_uid', '=', Input::get('project_uid'))->where('email', '=', Input::get('email'))->where('accept_date', '=', null)->where('decline_date', '=', null)->first();
     if ($invite) {
         return Response::json(array('error' => array('message' => Input::get('invitee_name') . ' already has a pending invitation')), 409);
     }
     // Model valid?
     //
     if ($projectInvitation->isValid()) {
         $projectInvitation->save();
         $projectInvitation->send(Input::get('confirm_route'), Input::get('register_route'));
         return $projectInvitation;
     } else {
         $errors = $projectInvitation->errors();
         return Response::make($errors->toJson(), 409);
     }
 }
开发者ID:pombredanne,项目名称:open-swamp,代码行数:26,代码来源:ProjectInvitationsController.php

示例10: getActivity

 public function getActivity(Request $request)
 {
     $me = GitHub::me()->show();
     $lastEventId = $request->session()->get('last_notification_id', false);
     $activity = [];
     $interval = 60;
     if ($lastEventId) {
         list($interval, $activity) = $this->findNewActivity($me['login'], $lastEventId);
         if ($activity) {
             $request->session()->set('last_notification_id', $activity[0]['id']);
             // Mark as read
             try {
                 GitHub::notification()->markRead();
             } catch (\Exception $e) {
                 // Github returns empty string for this endpoint but the API library tries to parse it as json
             }
             foreach ($activity as &$notice) {
                 $notice['html_url'] = $this->getRelatedHtmlUrl($notice['subject']);
             }
         }
     }
     $html = view('notifications.live', ['me' => $me, 'activity' => $activity]);
     $data = ['activity' => $html->render(), 'interval' => (int) $interval * 1000, 'count' => count($activity)];
     $response = \Illuminate\Support\Facades\Response::make(json_encode($data), 200);
     $response->header('Content-Type', 'application/json');
     return $response;
 }
开发者ID:cdsalmons,项目名称:my-github,代码行数:27,代码来源:LiveController.php

示例11: customer

 public function customer(UserInterface $user)
 {
     if (Gate::allows('is_customer', $user->getCustomer())) {
         return Response::json(['data' => $user->getCustomer()->entries]);
     }
     return Response::json([], 401);
 }
开发者ID:nq2916,项目名称:jot,代码行数:7,代码来源:PersonController.php

示例12: store

 /**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request, ImageServiceInterface $imageService)
 {
     $response_type = $request->get('responseType');
     // For CKEditor API
     // (http://docs.ckeditor.com/#!/guide/dev_file_browser_api)
     $funcNum = $request->get('CKEditorFuncNum');
     if (!$request->hasFile('upload')) {
         if ($response_type === 'json') {
             return Response::json(['description' => 'File not exists'], 422);
         }
         $url = '';
         $message = 'File invalid. Please choose another file.';
     } else {
         try {
             $fileName = $imageService->save($request->file('upload'));
             $url = $imageService->url($fileName);
             if ($response_type === 'json') {
                 return Response::json(['fileName' => $fileName, 'uploaded' => 1, 'url' => $url], 200, [], JSON_NUMERIC_CHECK);
             }
             $message = 'Image was loading successfully';
         } catch (\Exception $e) {
             $url = '';
             $message = 'File invalid. Please choose another file.';
         }
     }
     return "<script type='text/javascript'>\n                    window.parent.CKEDITOR.tools.callFunction(\n                        {$funcNum},\n                        '{$url}',\n                        '{$message}'\n                    );\n                </script>";
 }
开发者ID:B1naryStudio,项目名称:asciit,代码行数:33,代码来源:ImageController.php

示例13: template

 public function template()
 {
     $oferte = Input::get('nr_oferte');
     $controls = $this->controls($oferte);
     $html = View::make('oferta.partials.tabs.index')->with(compact('oferte', 'controls'))->render();
     return Response::json(['html' => $html]);
 }
开发者ID:binaryk,项目名称:credite,代码行数:7,代码来源:OfertaController.php

示例14: respond

 public function respond(Exception $exception)
 {
     // the default laravel console error handler really sucks - override it
     if ($this->isConsole()) {
         // if log_error is false and error_log is not set, fatal errors
         // should go to STDERR which, in the cli environment, is STDOUT
         if (ini_get('log_errors') === "1" && !ini_get('error_log') && $exception instanceof FatalErrorException) {
             return '';
         }
         // if the exception is not fatal, simply echo it and a newline
         return $exception . "\n";
     }
     if ($exception instanceof HttpExceptionInterface) {
         $statusCode = $exception->getStatusCode();
         $headers = $exception->getHeaders();
     } else {
         $statusCode = 500;
         $headers = array();
     }
     // if debug is false, show the friendly error message
     if ($this->app['config']->get('app.debug') === false) {
         if ($this->requestIsJson()) {
             return Response::json(array('errors' => array($this->app['translator']->get('smarterror::genericErrorTitle'))), $statusCode, $headers);
         } else {
             if ($view = $this->app['config']->get('smarterror::error-view')) {
                 return Response::view($view, array('referer' => $this->app['request']->header('referer')), $statusCode, $headers);
             }
         }
     }
     // if debug is true, do nothing and the default exception whoops page is shown
 }
开发者ID:hkonnet,项目名称:laravel-4-smart-errors,代码行数:31,代码来源:ExceptionResponder.php

示例15: getIndex

 /**
  * Index action.
  *
  * @return mixed
  */
 public function getIndex($type = null)
 {
     $container = Input::get('c');
     $files = Input::get('files', '');
     if (empty($type) || !in_array($type, array('style', 'script'))) {
         App::abort(404);
     }
     if (empty($container)) {
         App::abort(404);
     }
     $files = json_decode(base64_decode($files), true);
     if (empty($files) || !is_array($files)) {
         App::abort(404);
     }
     foreach ($files as $file) {
         Casset::container($container)->add(array_get($file, 'source'), array(), array_get($file, 'dependencies', array()));
     }
     $response = Response::make(Casset::container($container)->content($type));
     if ('style' == $type) {
         $response->headers->set('Content-Type', 'text/css');
     } else {
         $response->headers->set('Content-Type', 'application/json');
     }
     return $response;
 }
开发者ID:jooorooo,项目名称:laravel-casset,代码行数:30,代码来源:CassetController.php


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