本文整理汇总了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);
}
示例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();
}
示例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');
}
示例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);
}