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


PHP response函数代码示例

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


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

示例1: unauthenticated

 /**
  * Convert an authentication exception into an unauthenticated response.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Illuminate\Auth\AuthenticationException  $exception
  * @return \Illuminate\Http\Response
  */
 protected function unauthenticated($request, AuthenticationException $exception)
 {
     if ($request->expectsJson()) {
         return response()->json(['error' => 'Unauthenticated.'], 401);
     }
     return redirect()->guest('login');
 }
开发者ID:hownowbrowncow,项目名称:website,代码行数:14,代码来源:Handler.php

示例2: index

 /**
  * For autocompleting.
  * Select rows from both foods and recipes table.
  *
  * @VP: I feel like I should transform the foods and recipes here,
  * to be consistent, but then there would be so much stuff I don't need.
  * (For example, I only need the name and id for the recipes.)
  *
  * So I did use transformers, but it's a bit of a mess,
  * and I suppose there's a better way to write this code,
  * since I'm adding the
  * data attribute at the end just so it's consistent with
  * my other autocomplete responses.
  * @param Request $request
  * @return mixed
  */
 public function index(Request $request)
 {
     $typing = '%' . $request->get('typing') . '%';
     $foods = $this->foods($typing);
     //I didn't transform this because I only need the id and name
     $recipes = $this->recipes($typing)->toArray();
     $foods = $this->transform($this->createCollection($foods, new FoodTransformer()), ['units'])['data'];
     //Specify whether the menu item is a food or recipe
     foreach ($foods as $index => $food) {
         $foods[$index]['type'] = 'food';
     }
     $menu = $foods;
     foreach ($recipes as $recipe) {
         $recipe['type'] = 'recipe';
         $menu[] = $recipe;
     }
     //Sort by name and change the array indexes so they are ordered correctly, too
     //(Having the indexes ordered correctly makes it easier to test the ordering is correct)
     usort($menu, function ($a, $b) {
         return strcmp($a["name"], $b["name"]);
     });
     //So that for populating the autocomplete, there is a
     //data attribute like the food and exercise autocomplete responses
     $response = ['data' => $menu];
     return response($response, Response::HTTP_OK);
 }
开发者ID:JennySwift,项目名称:health-tracker,代码行数:42,代码来源:MenuController.php

示例3: index

 /**
  * @param string $model The model to list.
  * @return mixed
  */
 public function index(Request $request, $model)
 {
     if (!Auth::check()) {
         return response("Unauthorised", 401);
     }
     $user = Auth::user();
     if ($user->cannot('administrate')) {
         return response("Unauthorised", 401);
     }
     $class = $this->getModel($model);
     if (is_null($class)) {
         return response("No items found for this model {$model}", 404);
     }
     $pagination_enabled = config('crudapi.pagination.enabled');
     $perPage = config('crudapi.pagination.perPage');
     if ($pagination_enabled) {
         $items = $class->paginate($perPage);
     } else {
         $items = $class->all();
     }
     $fields = $class->getFillable();
     $data = $this->buildData();
     $data['items'] = $items;
     $data['model'] = $model;
     $data['fields'] = $fields;
     $data['uiframework'] = config('crudapi.framework', 'bs3');
     $data['timestamps'] = config('crudapi.admin.showTimestamps', false);
     $data['show_ids'] = config('crudapi.admin.showIds', false);
     return view('crudapi::admin.index', $data);
 }
开发者ID:azhany,项目名称:crud-api,代码行数:34,代码来源:AdminController.php

示例4: download

 public function download($id)
 {
     $file = File::findOrFail($id);
     $pathToFile = 'get_link_to_download/' . md5($file->name . time());
     FileHelpers::copy(storage_path('app') . '/' . $file->local_name, $pathToFile);
     return response()->download($pathToFile, $file->name, ['Content-Type'])->deleteFileAfterSend(true);
 }
开发者ID:quantbm,项目名称:RimDrive,代码行数:7,代码来源:FilesController.php

示例5: render

 /**
  * Render an exception into an HTTP response.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Exception  $e
  * @return \Illuminate\Http\Response
  */
 public function render($request, Exception $e)
 {
     /*if(NotFoundHttpException instanceof $e){*/
     return response()->view('welcome');
     /*}*/
     return parent::render($request, $e);
 }
开发者ID:nurolopher,项目名称:findsport,代码行数:14,代码来源:Handler.php

示例6: destroy

 public function destroy($id)
 {
     $todo = Todo::findOrFail($id);
     $this->authorize('touch', $todo);
     $todo->delete();
     return response($todo, 200);
 }
开发者ID:rosemalejohn,项目名称:dnsc-hris,代码行数:7,代码来源:TodoController.php

示例7: updateArticle

 public function updateArticle(Request $request, $id)
 {
     $article->title = $request->input('title');
     $article->content = $request->input('content');
     $article->save();
     return response()->json($article);
 }
开发者ID:rahul-8590,项目名称:lumenAngular,代码行数:7,代码来源:ArticleController.php

示例8: saveAdminUser

 public function saveAdminUser(SaveAdminUserPostRequest $request)
 {
     $user = User::create(['username' => $request->input('username'), 'displayname' => $request->input('displayname'), 'email' => $request->input('email'), 'password' => bcrypt($request->input('password')), 'user_role_id' => $request->input('role_id')]);
     $user->is_active = true;
     $user->save();
     return response()->json(['status' => 'success', 'message' => 'New Admin User Created.']);
 }
开发者ID:jysnkun05,项目名称:SEDPI-WebApp,代码行数:7,代码来源:UserSettingsController.php

示例9: postActualizarcosto

 public function postActualizarcosto(Request $req)
 {
     $detalle = DetalleArticulo::findOrFail($req->get('id'));
     $detalle->fill($req->only('costo_compra'));
     $detalle->save();
     return response()->json();
 }
开发者ID:armandolazarte,项目名称:amsrental-presupuestos,代码行数:7,代码来源:DetalleArticulosController.php

示例10: render

 public function render($request, Exception $e)
 {
     if ($e instanceof \Symfony\Component\HttpKernel\Exception\NotFoundHttpException) {
         return response(view('errors.missing'), 404);
     }
     return parent::render($request, $e);
 }
开发者ID:lmkhang,项目名称:mcntw,代码行数:7,代码来源:Handler.php

示例11: store

 public function store(Request $request)
 {
     //Seteo la zona horaria
     date_default_timezone_set('America/Argentina/Buenos_Aires');
     if ($request->ajax()) {
         $persona_registrada = DB::select('select * from personas WHERE  documento like "' . $request->username . '"');
         $personas = DB::select('select * FROM personas p1 INNER JOIN evento_persona t2 ON p1.id = t2.persona_id WHERE  p1.documento like "' . $request->username . '"' . ' and t2.evento_id = ' . $request->evento_id);
         if (!empty($personas) && is_array($personas)) {
             //verifico que el array tenga datos
             if ($this->validarAsistencias($personas, $request->evento_id)) {
                 //valido cantidad maxima de asistencias
                 if ($this->validarUltimoIngreso($personas, $request->evento_id)) {
                     //valido tolerancia
                     $this->insertAsistencia($personas);
                     //inserto asistencias
                 }
             }
             array_push($personas, ["valor" => Config::get('constant.MENSAJE')]);
             return response()->json($personas);
         } else {
             if (empty($persona_registrada)) {
                 array_push($personas, ["valor" => Config::get('constant.MENSAJE_ERROR')]);
             } else {
                 array_push($personas, ["valor" => Config::get('constant.MENSAJE_NO_PERTENECE_EVENTO')]);
             }
             return response()->json($personas);
         }
     }
 }
开发者ID:javparra,项目名称:jornadas,代码行数:29,代码来源:AsistenciaController.php

示例12: create

 /**
  * @return mixed
  */
 public function create()
 {
     $users = User::with('employee')->get()->reject(function ($user) {
         return $user->id === auth()->user()->id;
     });
     return response()->view('messages.create', with(compact('users')));
 }
开发者ID:rosemalejohn,项目名称:dnsc-hris,代码行数:10,代码来源:MessageController.php

示例13: resolveIdsToNames

 /**
  * @param \Illuminate\Http\Request $request
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function resolveIdsToNames(Request $request)
 {
     $ids = array_unique(explode(',', $request->ids));
     // Init the initial return array
     $response = [];
     // Populate any entries from the cache
     foreach ($ids as $id) {
         if (Cache::has($this->prefix . $id)) {
             $response[$id] = Cache::get($this->prefix . $id);
             unset($ids[$id]);
         }
     }
     // Call the EVE API for any outstanding ids that need
     // resolution
     if (!empty($ids)) {
         $pheal = app()->make('Seat\\Eveapi\\Helpers\\PhealSetup')->getPheal();
         foreach (array_chunk($ids, 30) as $id_chunk) {
             $names = $pheal->eveScope->CharacterName(['ids' => implode(',', $id_chunk)]);
             foreach ($names->characters as $result) {
                 Cache::forever($this->prefix . $result->characterID, $result->name);
                 $response[$result->characterID] = $result->name;
             }
         }
     }
     return response()->json($response);
 }
开发者ID:eveseat,项目名称:web,代码行数:31,代码来源:ResolveController.php

示例14: optimize

 public function optimize($hash)
 {
     $folder = $this->getImagePath($hash);
     //Check if image exists. If not, throw exception.
     if (is_null($folder)) {
         throw new Exception('Image does not exists.');
     }
     //Check if any etag is set.
     if (!empty(request()->instance()->getETags())) {
         return response(null)->setNotModified();
     }
     $newHeight = $this->getDimensionValue('h');
     $newWidth = $this->getDimensionValue('w');
     $this->image->readImage(sprintf('%s/%s', $folder, $hash));
     if (filter_var($newWidth, FILTER_VALIDATE_INT) && filter_var($newHeight, FILTER_VALIDATE_INT)) {
         $this->crop($newWidth, $newHeight);
     } else {
         if (filter_var($newWidth, FILTER_VALIDATE_INT) && $newHeight === 'auto') {
             $this->resize($newWidth, 0);
         } else {
             if (filter_var($newHeight, FILTER_VALIDATE_INT) && $newWidth === 'auto') {
                 $this->resize(0, $newHeight);
             }
         }
     }
     return response($this->image)->header('Pragma', 'Public')->header('Content-Type', $this->image->getImageMimeType())->setEtag(md5(sprintf('%s-%s', $hash, $_SERVER['QUERY_STRING'])))->setPublic();
 }
开发者ID:izupet,项目名称:laravel-flyimages,代码行数:27,代码来源:FlyImages.php

示例15: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @param  string|null  $guard
  * @return mixed
  */
 public function handle($request, Closure $next, $guard = null)
 {
     if ($this->auth->guard($guard)->guest()) {
         return response('Unauthorized.', 401);
     }
     return $next($request);
 }
开发者ID:ModelSolv,项目名称:swagger-codegen,代码行数:15,代码来源:Authenticate.php


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