本文整理汇总了PHP中app\Language::forget方法的典型用法代码示例。如果您正苦于以下问题:PHP Language::forget方法的具体用法?PHP Language::forget怎么用?PHP Language::forget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\Language
的用法示例。
在下文中一共展示了Language::forget方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: boot
/**
* Register any other events for your application.
*
* @param \Illuminate\Contracts\Events\Dispatcher $events
* @return void
*/
public function boot(DispatcherContract $events)
{
parent::boot($events);
Event::listen('language.change', function (Language $language) {
// Change application language
$language->apply()->remember();
// Update user's language
if ($user = Auth::user()) {
$user->language()->associate($language)->save();
}
// Feedback
Session::flash('success', sprintf(_('Language changed to %s'), $language->native_name));
});
Event::listen('auth.login', function (User $user) {
// Change application language to current user's language
if ($user->language instanceof Language) {
$user->language->apply()->remember();
}
// Stats
$user->increment('login_count');
$user->provider->increment('login_count');
// Feedback
Session::flash('success', sprintf(_('Logged in as %s'), $user));
});
Event::listen('auth.logout', function (User $user) {
// Feedback
Session::flash('success', _('Logged out'));
// Reset default application language
Language::forget();
});
}
示例2: handle
/**
* Handle the event.
*
* @param PodcastWasPurchased $event
* @return void
*/
public function handle(Logout $event)
{
// Access the user using $event->user...
// Reset default application language
Language::forget();
// Purge admin panel search results cache
Cache::forget('adminSearchResults' . $event->user->getKey());
}