Last active
February 4, 2017 23:54
-
-
Save exileed/846d76722da95292bedc6ddb09a566c1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Events\AddUserEvent; | |
use Illuminate\Queue\SerializesModels; | |
class AddUserEvent | |
{ | |
use SerializesModels; | |
public $user; | |
/** | |
* Create a new event instance. | |
* | |
* @param User $user | |
* @return void | |
*/ | |
public function __construct(User $user) | |
{ | |
$this->user = $user; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Providers; | |
use Illuminate\Support\Facades\Event; | |
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; | |
class EventServiceProvider extends ServiceProvider | |
{ | |
/** | |
* The event listener mappings for the application. | |
* | |
* @var array | |
*/ | |
protected $listen = [ | |
'App\Events\AddUserEvent' => [ | |
'App\Handlers\WelcomeMessageHandler', | |
], | |
//some many event | |
]; | |
/** | |
* Register any events for your application. | |
* | |
* @return void | |
*/ | |
public function boot() | |
{ | |
parent::boot(); | |
// | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Handlers; | |
class WelcomeMessageHandler | |
{ | |
public $repository; | |
public $log; | |
/** | |
* Create the event listener. | |
* | |
* @return void | |
*/ | |
public function __construct( UserRepository $userRepository, Log $log) | |
{ | |
$this->repository = $chatRepository; | |
$this->log = $log; | |
} | |
/** | |
* Handle the event. | |
* | |
* @param NewUserEvent $event | |
* | |
* @return void | |
*/ | |
public function handle(NewUserEvent $event) | |
{ | |
$user = $event->user; | |
//come code | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment