本文整理汇总了PHP中Illuminate\Foundation\Support\Providers\EventServiceProvider类的典型用法代码示例。如果您正苦于以下问题:PHP EventServiceProvider类的具体用法?PHP EventServiceProvider怎么用?PHP EventServiceProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EventServiceProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
User::deleting(function ($user) {
\Event::fire(new UserWasDeleted($user->id));
});
}
示例2: boot
/**
* Register any other events for your application.
*
* @param \Illuminate\Contracts\Events\Dispatcher $events
* @return void
*/
public function boot(DispatcherContract $events)
{
parent::boot($events);
$events->listen('auth.login', 'Ruysu\\Core\\Listeners\\AuthListener@onLogin');
$events->listen('Ruysu\\Core\\Events\\Auth\\UserRegistered', 'Ruysu\\Core\\Listeners\\AuthListener@onRegister');
$events->listen('Ruysu\\Core\\Events\\Auth\\UserActivated', 'Ruysu\\Core\\Listeners\\AuthListener@onActivate');
}
示例3: boot
/**
* Register any other events for your application.
*
* @param \Illuminate\Contracts\Events\Dispatcher $events
* @return void
*/
public function boot(DispatcherContract $events)
{
parent::boot($events);
Project::observe(new SlugGeneratorObserver());
Category::observe(new SlugGeneratorObserver());
Tag::observe(new SlugGeneratorObserver());
}
示例4: 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('Aacotroneo\\Saml2\\Events\\Saml2LoginEvent', function (Saml2LoginEvent $event) {
$user = $event->getSaml2User();
/*$userData = [
'id' => $user->getUserId(),
'attributes' => $user->getAttributes(),
'assertion' => $user->getRawSamlAssertion()
];*/
$laravelUser = User::where("username", "=", $user->getUserId())->get()->first();
if ($laravelUser != null) {
Auth::login($laravelUser);
} else {
//if first user then create it and login
$count = \App\User::all()->count();
if ($count == 0) {
$data = array();
$data['lastname'] = "";
$data['firstname'] = "";
$data['username'] = $user->getUserId();
$data['role'] = "admin";
$user = \App\User::create($data);
\Auth::login($user);
return \Redirect::to('/');
} else {
abort(401);
}
}
//if it does not exist create it and go on or show an error message
});
}
示例5: boot
public function boot()
{
// DispatcherContract $events
// $events
parent::boot();
//
}
示例6: boot
/**
* Register any other events for your application.
*
* @param \Illuminate\Contracts\Events\Dispatcher $events
*
* @return void
*/
public function boot(DispatcherContract $events)
{
parent::boot($events);
$this->registerDeleteEvents();
$this->registerCreateEvents();
BudgetLimit::saved(function (BudgetLimit $budgetLimit) {
$end = Navigation::addPeriod(clone $budgetLimit->startdate, $budgetLimit->repeat_freq, 0);
$end->subDay();
$set = $budgetLimit->limitrepetitions()->where('startdate', $budgetLimit->startdate->format('Y-m-d 00:00:00'))->where('enddate', $end->format('Y-m-d 00:00:00'))->get();
if ($set->count() == 0) {
$repetition = new LimitRepetition();
$repetition->startdate = $budgetLimit->startdate;
$repetition->enddate = $end;
$repetition->amount = $budgetLimit->amount;
$repetition->budgetLimit()->associate($budgetLimit);
try {
$repetition->save();
} catch (QueryException $e) {
Log::error('Trying to save new LimitRepetition failed: ' . $e->getMessage());
// @codeCoverageIgnore
}
} else {
if ($set->count() == 1) {
$repetition = $set->first();
$repetition->amount = $budgetLimit->amount;
$repetition->save();
}
}
});
}
示例7: boot
/**
* Register any other events for your application.
*
* @param \Illuminate\Contracts\Events\Dispatcher $events
* @return void
*/
public function boot(DispatcherContract $events)
{
parent::boot($events);
if (!$this->isLumen()) {
$this->publishes([$this->getConfigPath() => $this->app->make('path.config') . '/viewpresenter.php'], 'config');
}
}
示例8: boot
/**
* Register any other events for your application.
*
* @param \Illuminate\Contracts\Events\Dispatcher $events
*/
public function boot(DispatcherContract $events)
{
parent::boot($events);
if (!\Request::isMethod('GET')) {
$events->subscribe(PushNotificationHandler::class);
}
}
示例9: boot
/**
* Register any other events for your application.
*
* @param \Illuminate\Contracts\Events\Dispatcher $events
* @return void
*/
public function boot(DispatcherContract $events)
{
parent::boot($events);
User::creating(function ($user) {
//
});
}
示例10: boot
/**
* Register any other events for your application.
*
* @param \Illuminate\Contracts\Events\Dispatcher $events
* @return void
*/
public function boot(DispatcherContract $events)
{
parent::boot($events);
AttributeType::deleting(function ($attr) {
$sub_attrs = Attribute::where('type_id', '=', $attr->id)->get();
foreach ($sub_attrs as $sa) {
$sa->delete();
}
});
EntityType::deleting(function ($entity) {
$entities = $entity->entities;
foreach ($entities as $e) {
$e->delete();
}
});
Entity::deleting(function ($entity) {
$alarms = $entity->alarms;
foreach ($alarms as $a) {
$a->delete();
}
});
Alarm::deleting(function ($alarm) {
$reminders = $alarm->history;
foreach ($reminders as $r) {
$r->delete();
}
});
}
示例11: boot
/**
* Register any other events for your application.
*
* @param \Illuminate\Contracts\Events\Dispatcher $events
* @return void
*/
public function boot(DispatcherContract $events)
{
parent::boot($events);
$events->listen('eloquent.saving: *', function ($model) {
\File::append('audit', "Table {$model->getTable()} has been saved." . PHP_EOL);
});
}
示例12: 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();
});
}
示例13: boot
/**
* Register any other events for your application.
*
* @param \Illuminate\Contracts\Events\Dispatcher $events
* @return void
*/
public function boot(DispatcherContract $events)
{
parent::boot($events);
Form::component('bsText', 'shared.components.text', ['name', 'label', 'required' => false, 'unit' => false, 'inputCol' => 4]);
Form::component('bsNumber', 'shared.components.number', ['name', 'label', 'required' => false, 'unit' => false, 'inputCol' => 4]);
Form::component('bsTextarea', 'shared.components.textarea', ['name', 'label', 'required' => false, 'rows' => 4]);
Form::component('bsSelect', 'shared.components.select', ['name', 'label', 'choice', 'required' => false, 'unit' => false, 'inputCol' => 4]);
Form::component('twoSelect', 'shared.components.twoSelect', ['label', 'nameA', 'choiceA', 'requiredA' => false, 'unitA' => false, 'nameB', 'choiceB', 'requiredB' => false, 'unitB' => false]);
Form::component('bsDate', 'shared.components.date', ['name', 'label', 'required' => false]);
/**
* Sugar components
*/
// playList must Laravel Collection object
Form::component('playList', 'shared.sugar.playList', ['name', 'playList']);
Form::component('basin', 'shared.sugar.basin', ['name']);
Form::component('province', 'shared.sugar.province', ['name']);
Form::component('clarified', 'shared.sugar.clarified', ['name']);
Form::component('analogTo', 'shared.sugar.analogTo', ['name']);
Form::component('analogDistance', 'shared.sugar.analogDistance', ['name']);
Form::component('shore', 'shared.sugar.shore', ['name']);
Form::component('terrain', 'shared.sugar.terrain', ['name']);
Form::component('nearbyField', 'shared.sugar.nearbyField', ['name']);
Form::component('nearbyInfra', 'shared.sugar.nearbyInfra', ['name']);
Form::component('remark', 'shared.sugar.remark', ['name', 'required' => false]);
Form::component('lateMethod', 'shared.sugar.lateMethod', ['name']);
Form::component('seismicImage', 'shared.sugar.seismicImage', ['name']);
Form::component('latitude', 'shared.sugar.latitude', ['name', 'required' => true]);
Form::component('longitude', 'shared.sugar.longitude', ['name', 'required' => true]);
Form::component('survey', 'shared.sugar.survey', ['name' => 'survey', 'choice']);
}
示例14: boot
/**
* Register any other events for your application.
*
* @param \Illuminate\Contracts\Events\Dispatcher $events
* @return void
*/
public function boot(DispatcherContract $events)
{
parent::boot($events);
$events->listen('auth.logout', function ($event) {
Session::flush();
});
}
示例15: boot
/**
* Register any other events for your application.
*
* @param \Illuminate\Contracts\Events\Dispatcher $events
* @return void
*/
public function boot(DispatcherContract $events)
{
parent::boot($events);
User::creating(function ($user) {
$user->ip_address = Request::ip();
$user->confirmation_code = str_random(60);
$user->referral_code = str_random(10);
$user->referral_secret = str_random(10);
Session::put(Config::get('prelaunch.session:referral_secret'), $user->referral_secret);
});
User::created(function ($user) {
$user->sendConfirmation();
});
# query logger
if (App::environment('local')) {
Event::listen('illuminate.query', function ($sql, $bindings, $time) {
for ($i = 0; $i < sizeof($bindings); $i++) {
if ($bindings[$i] instanceof DateTime) {
$bindings[$i] = $bindings[$i]->getTimestamp();
}
}
Log::info(sprintf("%s (%s) : %s", $sql, implode(",", $bindings), $time));
});
}
}