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


PHP Response::make方法代码示例

本文整理汇总了PHP中Response::make方法的典型用法代码示例。如果您正苦于以下问题:PHP Response::make方法的具体用法?PHP Response::make怎么用?PHP Response::make使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Response的用法示例。


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

示例1: index

 /**
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     // Use content negotiation to determine the correct format to return
     $negotiator = new \Negotiation\FormatNegotiator();
     $acceptHeader = Request::header('accept');
     // Set priorities to json (if the app requests json provide it in favor of html)
     $priorities = array('application/json', 'text/html', '*/*');
     // Get the best appropriate content type
     $result = $negotiator->getBest($acceptHeader, $priorities);
     // Default to html if $result is not set
     $val = "text/html";
     if (isset($result)) {
         $val = $result->getValue();
     }
     // See what kind of content we should return
     switch ($val) {
         case "text/html":
             // In case we want to return html, just let
             // Laravel render the view and send the headers
             return Response::view('route.planner')->header('Content-Type', "text/html")->header('Vary', 'accept');
             break;
         case "application/json":
         default:
             // In case we want to return JSON(LD) or something else, generate
             // our JSON by calling our static function 'getJSON()'
             return Response::make($this::getJSON())->header('Content-Type', "application/json")->header('Vary', 'accept');
             break;
     }
 }
开发者ID:elroyK,项目名称:hyperRail,代码行数:32,代码来源:RouteController.php

示例2: update

 public function update(Request $request, $id)
 {
     try {
         $params = $request->all();
         $reportId = $id;
         $report = CrimeReportsModel::find($id);
         if (isset($params['delete_flag'])) {
             $report->delete_flag = 'y';
             $report->save();
             return response()->json(['message' => 'deleted'], 200);
         } else {
             $newStatus = '';
             switch ($params['status']) {
                 case 'o':
                     $newStatus = 'p';
                     break;
                 case 'p':
                     $newStatus = 'r';
                     break;
                 case 'r':
                     $newStatus = 'r';
                     break;
                 default:
                     $newStatus = 'd';
                     break;
             }
             $report->status = $newStatus;
             $report->save();
             return response()->json(['message' => 'success'], 200);
         }
     } catch (ModelNotFoundException $e) {
         return Response::make('Not Found', 404);
     }
 }
开发者ID:bivinka,项目名称:iSumbong,代码行数:34,代码来源:CrimeReportsController.php

示例3: getExport

 public function getExport($statistic)
 {
     $title = $statistic->name;
     $type = \Input::get('type');
     $arrColumnName = $statistic->getColumnNameArray();
     $table = $statistic->getResult();
     switch ($type) {
         case 'csv':
             $output = '';
             $output .= implode(",", $arrColumnName) . "\r\n";
             foreach ($table as $row) {
                 $output .= implode(",", $row) . "\r\n";
             }
             $headers = array('Content-Type' => 'text/csv', 'Content-Disposition' => 'attachment; filename="' . $statistic->name . '_' . date('Y_m_d_His') . '.csv"');
             return \Response::make(rtrim($output, "\r\n"), 200, $headers);
         case 'excel':
             $output = '<table><thead><tr>';
             foreach ($arrColumnName as $columnName) {
                 $output = $output . '<th>' . $columnName . '</th>';
             }
             $output = $output . '</tr></thead><tbody>';
             foreach ($table as $result) {
                 $output = $output . '<tr>';
                 foreach ($result as $res) {
                     $output = $output . '<td>' . $res . '</td>';
                 }
                 $output = $output . '</tr>';
             }
             $output = $output . '<tfoot><tr><td colspan="' . count($arrColumnName) . '">' . $statistic->name . '</td></tr></tfoot></table>';
             $headers = array('Pragma' => 'public', 'Expires' => 'public', 'Cache-Control' => 'must-revalidate, post-check=0, pre-check=0', 'Cache-Control' => 'private', 'Content-Type' => 'application/vnd.ms-excel', 'Content-Disposition' => 'attachment; filename=' . $statistic->name . '_' . date('Y_m_d_His') . '.xls', 'Content-Transfer-Encoding' => ' binary');
             return \Response::make($output, 200, $headers);
     }
     return \View::make(\Config::get('app.admin_template') . '/statistics/result', compact('title', 'statistic'));
 }
开发者ID:davin-bao,项目名称:statistics,代码行数:34,代码来源:HasStatisticsController.php

示例4: getJavascript

 public function getJavascript()
 {
     $contents = View::make('translations');
     $response = Response::make($contents);
     $response->header('Content-Type', 'application/javascript');
     return $response;
 }
开发者ID:Aranjedeath,项目名称:l4-starter,代码行数:7,代码来源:BlogController.php

示例5: create

 public function create($type = 'csv')
 {
     try {
         $export = static::getExportForType($type);
     } catch (Exception $e) {
         App::abort(404);
     }
     $export->user_id = Auth::user()->id;
     $export->filename = $export->generateFilename();
     $export->path = $export->folderPath();
     $export->setLogbooks(Input::get('logbooks'));
     $save = Input::has('save') ? (bool) Input::get('save') : true;
     if ($export->run($save)) {
         if ($save == false) {
             $res = Response::make($export->content);
             $res->header('Content-type', $export->getContentType());
             return $res;
         } else {
             $export->save();
             return Response::download($export->fullPath(), $export->filename, ['Content-type' => $export->getContentType()]);
         }
     } else {
         return Redirect::to(action('ExportsController@index'))->with('message', ['content' => 'Er is iets mis gegaan met exporteren.', 'class' => 'danger']);
     }
 }
开发者ID:y0sh1,项目名称:logboek,代码行数:25,代码来源:ExportsController.php

示例6: index

 /**
  * Gets an array of statements.
  * https://github.com/adlnet/xAPI-Spec/blob/master/xAPI.md#723-getstatements
  * @param [String => mixed] $options
  * @return Response
  */
 public function index($options)
 {
     // Gets the acceptable languages.
     $langs = LockerRequest::header('Accept-Language', []);
     $langs = is_array($langs) ? $langs : explode(',', $langs);
     $langs = array_map(function ($lang) {
         return explode(';', $lang)[0];
     }, $langs);
     // Gets the params.
     $params = LockerRequest::all();
     if (isset($params['agent'])) {
         $decoded_agent = json_decode($params['agent']);
         if ($decoded_agent !== null) {
             $params['agent'] = $decoded_agent;
         }
     }
     // Gets an index of the statements with the given options.
     list($statements, $count, $opts) = $this->statements->index(array_merge(['langs' => $langs], $params, $options));
     // Defines the content type and body of the response.
     if ($opts['attachments'] === true) {
         $content_type = 'multipart/mixed; boundary=' . static::BOUNDARY;
         $body = $this->makeAttachmentsResult($statements, $count, $opts);
     } else {
         $content_type = 'application/json;';
         $body = $this->makeStatementsResult($statements, $count, $opts);
     }
     // Creates the response.
     return \Response::make($body, 200, ['Content-Type' => $content_type, 'X-Experience-API-Consistent-Through' => Helpers::getCurrentDate()]);
 }
开发者ID:hsz-develop,项目名称:LearningLocker--learninglocker,代码行数:35,代码来源:StatementIndexController.php

示例7: subscribe

 public function subscribe()
 {
     $rules = ['email' => 'required|email'];
     $validator = Validator::make(Input::all(), $rules);
     $contents = json_encode(['message' => 'Your subscription was unsuccessful.']);
     $failure = Response::make($contents, 200);
     $failure->header('Content-Type', 'text/json');
     if ($validator->fails()) {
         return $failure;
     }
     $subscription = new Subscription();
     $subscription->email = Input::get('email');
     $subscription->active = 1;
     $subscription->save();
     $email = Input::get('email');
     $subject = "Subscribe {$email} to Newsletter";
     #Shoot email to subscription service
     Mail::send('emails.subscription', array('email' => $email), function ($message) use($subject) {
         $message->to('newsletter@chenenetworks.com')->subject($subject);
     });
     $contents = json_encode(['message' => 'Your subscription was successful.']);
     $success = Response::make($contents, 200);
     $success->header('Content-Type', 'text/json');
     return $success;
 }
开发者ID:RainbowSeven,项目名称:la-chene,代码行数:25,代码来源:SubscriptionController.php

示例8: view

 /**
  * Emulate a call to index.php?p=$vanilla_module_path
  * Much of this ripped out of Vanilla's index.php
  */
 public function view($segments)
 {
     // if a static asset, return it outright
     $asset = $this->is_static_asset($segments);
     if ($asset) {
         return \Response::make(\File::get($asset))->header('Content-Type', $this->get_content_type($asset));
     }
     // otherwise, dispatch into vanilla
     $user = $this->user;
     $bootstrap = new VanillaBootstrap();
     $bootstrap->call(function () use($user, $segments) {
         // Create the session and stuff the user in
         \Gdn::Authenticator()->SetIdentity($user->getKey(), false);
         \Gdn::Session()->Start(false, false);
         \Gdn::Session()->SetPreference('Authenticator', 'Gdn_Authenticator');
         // Create and configure the dispatcher.
         $Dispatcher = \Gdn::Dispatcher();
         $EnabledApplications = \Gdn::ApplicationManager()->EnabledApplicationFolders();
         $Dispatcher->EnabledApplicationFolders($EnabledApplications);
         $Dispatcher->PassProperty('EnabledApplications', $EnabledApplications);
         // Process the request.
         $Dispatcher->Start();
         $Dispatcher->Dispatch(implode('/', $segments));
     });
 }
开发者ID:bishopb,项目名称:laravel-forums,代码行数:29,代码来源:VanillaRunner.php

示例9: receive

 public function receive()
 {
     $request = \Request::instance();
     if (!$this->goCardless->validateWebhook($request->getContent())) {
         return \Response::make('', 403);
     }
     $parser = new \BB\Services\Payment\GoCardlessWebhookParser();
     $parser->parseResponse($request->getContent());
     switch ($parser->getResourceType()) {
         case 'bill':
             switch ($parser->getAction()) {
                 case 'created':
                     $this->processNewBills($parser->getBills());
                     break;
                 case 'paid':
                     $this->processPaidBills($parser->getBills());
                     break;
                 default:
                     $this->processBills($parser->getAction(), $parser->getBills());
             }
             break;
         case 'pre_authorization':
             $this->processPreAuths($parser->getAction(), $parser->getPreAuthList());
             break;
         case 'subscription':
             $this->processSubscriptions($parser->getSubscriptions());
             break;
     }
     return \Response::make('Success', 200);
 }
开发者ID:adamstrawson,项目名称:BBMembershipSystem,代码行数:30,代码来源:GoCardlessWebhookController.php

示例10: register

 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     // Add the namespace to config
     $this->app['config']->package('onigoetz/imagecache', __DIR__ . '/../../config');
     $config = $this->app['config']->get('imagecache::imagecache');
     //TODO :: externalize that
     $toolkit = 'gd';
     // Stopwatch - must be registered so the application doesn't fail if the profiler is disabled
     $this->app['imagecache'] = $this->app->share(function () use($config, $toolkit) {
         return new Manager($config, $toolkit);
     });
     //PHP 5.3 compatibility
     $app = $this->app;
     $url = "{$config['path_images']}/{$config['path_cache']}/{preset}/{file}";
     $this->app['router']->get($url, function ($preset, $file) use($app) {
         try {
             $final_file = $app['imagecache']->handleRequest($preset, $file);
         } catch (InvalidPresetException $e) {
             return \Response::make('Invalid preset', 404);
         } catch (NotFoundException $e) {
             return \Response::make('File not found', 404);
         }
         if (!$final_file) {
             return \Response::make('Dunno what happened', 500);
         }
         //TODO :: be more "symfony reponse" friendly
         $transfer = new Transfer();
         $transfer->transfer($final_file);
         exit;
     })->where('file', '.*');
 }
开发者ID:asins,项目名称:imagecache,代码行数:36,代码来源:ImagecacheServiceProvider.php

示例11: boot

 /**
  * Bootstrap the application events.
  *
  * @return void
  */
 public function boot()
 {
     $app = $this->app;
     $app['config']->package('barryvdh/laravel-debugbar', $this->guessPackagePath() . '/config');
     if (!$this->shouldUseMiddleware()) {
         $app->after(function ($request, $response) use($app) {
             $debugbar = $app['debugbar'];
             $debugbar->modifyResponse($request, $response);
         });
     }
     $this->app['router']->get('_debugbar/open', array('as' => 'debugbar.openhandler', function () use($app) {
         $debugbar = $app['debugbar'];
         if (!$debugbar->isEnabled()) {
             $app->abort('500', 'Debugbar is not enabled');
         }
         $openHandler = new \DebugBar\OpenHandler($debugbar);
         $data = $openHandler->handle(null, false, false);
         return \Response::make($data, 200, array('Content-Type' => 'application/json'));
     }));
     if ($this->app['config']->get('laravel-debugbar::config.enabled')) {
         /** @var LaravelDebugbar $debugbar */
         $debugbar = $this->app['debugbar'];
         $debugbar->boot();
     }
 }
开发者ID:aaronbullard,项目名称:litmus,代码行数:30,代码来源:ServiceProvider.php

示例12: image

 public function image()
 {
     $key = strip_tags(\Route::input('key'));
     $key = str_replace('.png', '', $key);
     if (empty($key)) {
         return redirect('/');
     } else {
         $result = \DB::table('post')->where('post_key', $key)->first();
         if ($result->post_type == 3) {
             $text = $result->post_message;
             $text = $this->handleText($text);
             $image = $this->warpTextImage($text);
             ob_start();
             imagepng($image, null, 9, null);
             $image = ob_get_contents();
             ob_end_clean();
             @imagedestroy($image);
             $response = \Response::make($image);
             $response->header('Content-Type', 'image/png');
             return $response;
         } else {
             return redirect('/');
         }
     }
 }
开发者ID:kxgen,项目名称:facebook-anonymous-publisher,代码行数:25,代码来源:ImageController.php

示例13: handle

 public function handle($request, \Closure $next)
 {
     $auth0 = \App::make('auth0');
     // Get the encrypted user JWT
     $authorizationHeader = $request->header("Authorization");
     $encUser = str_replace('Bearer ', '', $authorizationHeader);
     if (trim($encUser) == '') {
         return \Response::make("Unauthorized user", 401);
     }
     try {
         $jwtUser = $auth0->decodeJWT($encUser);
     } catch (CoreException $e) {
         return \Response::make("Unauthorized user", 401);
     } catch (Exception $e) {
         echo $e;
         exit;
     }
     // if it does not represent a valid user, return a HTTP 401
     $user = $this->userRepository->getUserByDecodedJWT($jwtUser);
     if (!$user) {
         return \Response::make("Unauthorized user", 401);
     }
     // lets log the user in so it is accessible
     \Auth::login($user);
     // continue the execution
     return $next($request);
 }
开发者ID:carnevalle,项目名称:laravel-auth0,代码行数:27,代码来源:Auth0JWTMiddleware.php

示例14: metadata

 /**
  * Generate local sp metadata.
  *
  * @return \Illuminate\Http\Response
  */
 public function metadata()
 {
     $metadata = $this->saml2Auth->getMetadata();
     $response = Response::make($metadata, 200);
     $response->header('Content-Type', 'text/xml');
     return $response;
 }
开发者ID:avanderbergh,项目名称:laravel-schoology,代码行数:12,代码来源:Saml2Controller.php

示例15: image

 public function image()
 {
     if (!Auth::check()) {
         Session::flash('redirect', URL::current());
         return Redirect::route('login');
     }
     $relativePath = Input::get('path');
     $filePath = Input::get('file');
     $path = Path::fromRelative($relativePath);
     if (!$path->exists()) {
         App::abort(404, 'Archive not found');
     }
     $archive = Archive\Factory::open($path);
     $imageStream = $archive->getEntryStream($filePath);
     $imageData = stream_get_contents($imageStream);
     $response = Response::make($imageData);
     $ext = pathinfo($filePath, PATHINFO_EXTENSION);
     switch ($ext) {
         case 'jpg':
         case 'jpeg':
             $response->header('Content-Type', 'image/jpeg');
             break;
         case 'png':
             $response->header('Content-Type', 'image/png');
             break;
     }
     $response->header('Last-Modified', gmdate('D, d M Y H:i:s', $path->getMTime()) . ' GMT');
     $response->header('Expires', gmdate('D, d M Y H:i:s', strtotime('+1 year')) . ' GMT');
     $response->header('Cache-Control', 'public');
     return $response;
 }
开发者ID:qqueue,项目名称:MangaIndex,代码行数:31,代码来源:ReaderController.php


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