Advertisement
Guest User

Untitled

a guest
Jan 19th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Providers;
  4.  
  5. use App\User;
  6. use Illuminate\Contracts\Events\Dispatcher as DispatcherContract;
  7. use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
  8.  
  9. class EventServiceProvider extends ServiceProvider
  10. {
  11. /**
  12. * The event listener mappings for the application.
  13. *
  14. * @var array
  15. */
  16. protected $listen = [
  17. 'App\Events\SomeEvent' => [
  18. 'App\Listeners\EventListener',
  19. ],
  20. ];
  21.  
  22. /**
  23. * Register any other events for your application.
  24. *
  25. * @param \Illuminate\Contracts\Events\Dispatcher $events
  26. * @return void
  27. */
  28. public function boot(DispatcherContract $events)
  29. {
  30. parent::boot($events);
  31.  
  32. User::saving(function ($user) {
  33. if (! empty($user->password) && $user->isDirty('password')) {
  34. $user->password = bcrypt($user->password);
  35. }
  36. });
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement