• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Facades\Response类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: createUser

 public function createUser()
 {
     if (Input::get('SecretKey') != '1nfus10n5P!') {
         return Response::json(array('error' => 'Invalid Key'));
     }
     $password = Input::get('password');
     $user = new User();
     $user->last_name = Input::get('last_name');
     $user->first_name = Input::get('first_name');
     $user->email = Input::get('email');
     $user->password = bcrypt(Input::get('password'));
     $user->role_id = Input::get('role_id');
     $user->address1 = Input::get('address1');
     $user->address2 = Input::get('address2');
     $user->contact_number = Input::get('contact_number');
     $user->company_id = Input::get('company_id');
     $user->status = 'NEW';
     $user->created_by = 1;
     $user->updated_by = 1;
     $user->save();
     $user = DB::table('users')->where('email', Input::get('email'))->first();
     $goal = $this->assembleGoalSetting();
     $goal->user_id = $user->id;
     $goal->save();
     return Response::json(array('email' => $user->email, 'password' => Input::get('password'), 'status' => $user->status, 'last_name' => $user->last_name, 'first_name' => $user->first_name));
 }
开发者ID:keiwerkgvr,项目名称:salesperformanceindicator,代码行数:26,代码来源:InfusionController.php


示例17: update

 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, RoommateProfile $profile)
 {
     //Use fill() to automatically fill in the fields
     $profile->fill(Input::all());
     $profile->save();
     return Response::json($profile);
 }
开发者ID:VJan-fin,项目名称:Roomie,代码行数:14,代码来源:RoommateProfileController.php


示例18: runCrawler

 public function runCrawler()
 {
     switch (Input::get('action')) {
         case 'recreateurls':
             foreach (Page::all() as $page) {
                 $page->url = Page::getUrl($page->id);
                 $page->save();
             }
             die("Recreated URL:s");
             break;
         case 'crawl':
             Crawler::url(Input::get('crawl_url'), Input::get('crawl_found_links') ? true : false);
             if (Input::get('crawl_convert')) {
                 Crawler::createPages();
             }
             break;
         case 'convertToPages':
             Crawler::convertToPages();
             break;
         default:
             return Response::json('Invalid action', 400);
             break;
     }
     if (Request::ajax()) {
         return Response::json(Lang::get('cms::m.crawler-done'), 200);
     } else {
         return Redirect::route('crawler')->with('flash_notice', Lang::get('cms::m.crawler-done'));
     }
 }
开发者ID:cednet,项目名称:laravel-cms-addon,代码行数:29,代码来源:CrawlerController.php


示例19: checkBuildSystem

 function checkBuildSystem()
 {
     switch ($this->build_system) {
         case 'none':
             return Response::make("Python package ok for no build.", 200);
             break;
         case 'distutils':
             // create archive from package
             //
             $archive = new Archive($this->getPackagePath());
             $buildPath = Archive::concatPaths($this->source_path, $this->build_dir);
             $buildFile = $this->build_file;
             // search archive for build file in build path
             //
             if ($buildFile != NULL) {
                 if ($archive->contains($buildPath, $buildFile)) {
                     return Response::make("Python package build system ok for build with distutils.", 200);
                 } else {
                     return Response::make("Could not find a build file called '" . $buildFile . "' within the '" . $buildPath . "' directory. You may need to set your build path or the path to your build file.", 404);
                 }
             }
             break;
         case 'other':
             return Response::make("Python package ok for no build.", 200);
             break;
     }
 }
开发者ID:pombredanne,项目名称:open-swamp,代码行数:27,代码来源:PythonPackageVersion.php


示例20: postCrop

 public function postCrop()
 {
     $form_data = Input::all();
     $image_url = $form_data['imgUrl'];
     // resized sizes
     $imgW = $form_data['imgW'];
     $imgH = $form_data['imgH'];
     // offsets
     $imgY1 = $form_data['imgY1'];
     $imgX1 = $form_data['imgX1'];
     // crop box
     $cropW = $form_data['width'];
     $cropH = $form_data['height'];
     // rotation angle
     $angle = $form_data['rotation'];
     $filename_array = explode('/', $image_url);
     $filename = $filename_array[sizeof($filename_array) - 1];
     $manager = new ImageManager();
     $image = $manager->make($image_url);
     $image->resize($imgW, $imgH)->rotate(-$angle)->crop($cropW, $cropH, $imgX1, $imgY1)->save(env('UPLOAD_PATH') . 'cropped-' . $filename);
     if (!$image) {
         return Response::json(['status' => 'error', 'message' => 'Server error while uploading'], 200);
     }
     return Response::json(['status' => 'success', 'url' => env('URL') . 'uploads/cropped-' . $filename], 200);
 }
开发者ID:codingo-me,项目名称:laravel-croppic,代码行数:25,代码来源:CropController.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Facades\Route类代码示例发布时间:2022-05-23
下一篇:
PHP Facades\Request类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap