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


PHP City::findByIATA方法代码示例

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


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

示例1: handle

 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure                 $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     // If the user isn't logged in or they are part of a different city
     // deny access, otherwise go for it. Might be worth adding a message to
     // explain what happened on redirect.
     $city = City::findByIATA($request->route()->getParameter('city'))->first();
     if ($this->auth->guest()) {
         if ($request->ajax()) {
             return response('Unauthorized.', 401);
         } else {
             Notification::error('You need to be logged in to view that.');
             return redirect()->guest('auth/login');
         }
     } else {
         if ($city && $this->auth->user()->city_id !== $city->id) {
             Notification::error('You don\'t have permissions for that city.');
             if ($request->ajax()) {
                 return response('Unauthorized.', 401);
             } else {
                 return redirect('/' . $city->iata);
             }
         }
     }
     return $next($request);
 }
开发者ID:EMT,项目名称:see-do,代码行数:33,代码来源:Authenticate.php

示例2: down

 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     $city = City::findByIATA('nyc')->first();
     $event = Event::where('city_id', '=', $city->id);
     $city->delete();
     $event->delete();
 }
开发者ID:EMT,项目名称:see-do,代码行数:12,代码来源:2016_02_16_114627_seed_nyc_testing_city_and_event.php

示例3: update

 /**
  * Update the specified resource in storage.
  *
  * @param \Illuminate\Http\Request $request
  * @param Event                    $event
  *
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $iata)
 {
     // dont let the request go through unless the user matches the city id.
     // This ^ should be a middleware.
     $city = City::findByIATA($iata)->first();
     $this->validate($request, ['name' => 'required', 'iata' => 'unique:cities,iata,' . $city->iata . ',iata', 'twitter_consumer_key' => 'required', 'twitter_consumer_secret' => 'required', 'twitter_access_token' => 'required', 'twitter_access_token_secret' => 'required']);
     $city->fill(Input::all());
     $city->save();
     return redirect('/' . $city->iata)->with('message', 'City details updated');
 }
开发者ID:EMT,项目名称:see-do,代码行数:18,代码来源:CitiesController.php

示例4: futureEventsByCityIATA

 /**
  * Returns all events in with time_end in the future.
  *
  * @return Collection A collection of Events
  */
 public static function futureEventsByCityIATA($city_code)
 {
     $city = City::findByIATA($city_code)->first();
     return self::futureEvents()->where('city_id', '=', $city->id);
 }
开发者ID:EMT,项目名称:see-do,代码行数:10,代码来源:Event.php


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