{"action":"created","issue":{"url":"https://api.github.com/repos/laravel/framework/issues/10016","labels_url":"https://api.github.com/repos/laravel/framework/issues/10016/labels{/name}","comments_url":"https://api.github.com/repos/laravel/framework/issues/10016/comments","events_url":"https://api.github.com/repos/laravel/framework/issues/10016/events","html_url":"https://github.com/laravel/framework/issues/10016","id":102537293,"number":10016,"title":"[5.1] Event Listeners do not receive the event, but the model instead","user":{"login":"Francismori7","id":520647,"avatar_url":"https://avatars.githubusercontent.com/u/520647?v=3","gravatar_id":"","url":"https://api.github.com/users/Francismori7","html_url":"https://github.com/Francismori7","followers_url":"https://api.github.com/users/Francismori7/followers","following_url":"https://api.github.com/users/Francismori7/following{/other_user}","gists_url":"https://api.github.com/users/Francismori7/gists{/gist_id}","starred_url":"https://api.github.com/users/Francismori7/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Francismori7/subscriptions","organizations_url":"https://api.github.com/users/Francismori7/orgs","repos_url":"https://api.github.com/users/Francismori7/repos","events_url":"https://api.github.com/users/Francismori7/events{/privacy}","received_events_url":"https://api.github.com/users/Francismori7/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-08-22T13:32:10Z","updated_at":"2015-08-22T15:10:04Z","closed_at":"2015-08-22T15:09:28Z","body":"```bash\r\nErrorException in InvalidateClientsCache.php line 24: Argument 1 passed to App\\Listeners\\InvalidateClientsCache::handle() must be an instance of App\\Events\\ClientWasCreated, instance of App\\Client given\r\n```\r\n\r\nOkay so I have multiple events, let's take one here for the sake of an exemple:\r\n\r\n```php\r\nclass ClientWasCreated extends Event\r\n{\r\n    use SerializesModels;\r\n    /**\r\n     * @var Client\r\n     */\r\n    public $client;\r\n\r\n    /**\r\n     * Create a new event instance.\r\n     *\r\n     * @param Client $client\r\n     */\r\n    public function __construct(Client $client)\r\n    {\r\n        $this->client = $client;\r\n    }\r\n\r\n    /**\r\n     * Get the channels the event should be broadcast on.\r\n     *\r\n     * @return array\r\n     */\r\n    public function broadcastOn()\r\n    {\r\n        return ['clients'];\r\n    }\r\n}\r\n```\r\n\r\nAnd here is the listener, it is properly set up, and is properly fired if I remove TYPE-HINTING in the handle() method:\r\n\r\n```php\r\nclass InvalidateClientsCache\r\n{\r\n    /**\r\n     * Create the event listener.\r\n     */\r\n    public function __construct()\r\n    {\r\n        //\r\n    }\r\n\r\n    /**\r\n     * Handle the event.\r\n     *\r\n     * @param Client $client\r\n     */\r\n    public function handle(ClientWasCreated $event)\r\n    {\r\n        dd($event->client);\r\n\r\n        if (Cache::has('clients')) {\r\n            Cache::forget('clients');\r\n        }\r\n    }\r\n}\r\n```\r\n\r\nIf I remove the type-hinting of ClientWasCreated, I also get an error, client is not defined in the the passed object, because the passed object is the model itself.\r\n\r\nI have no idea what is going on here, my other projects seem to work fine with EVENTS type-hinted in the listeners, this one just calls straight the model itself."},"comment":{"url":"https://api.github.com/repos/laravel/framework/issues/comments/133713882","html_url":"https://github.com/laravel/framework/issues/10016#issuecomment-133713882","issue_url":"https://api.github.com/repos/laravel/framework/issues/10016","id":133713882,"user":{"login":"GrahamCampbell","id":2829600,"avatar_url":"https://avatars.githubusercontent.com/u/2829600?v=3","gravatar_id":"","url":"https://api.github.com/users/GrahamCampbell","html_url":"https://github.com/GrahamCampbell","followers_url":"https://api.github.com/users/GrahamCampbell/followers","following_url":"https://api.github.com/users/GrahamCampbell/following{/other_user}","gists_url":"https://api.github.com/users/GrahamCampbell/gists{/gist_id}","starred_url":"https://api.github.com/users/GrahamCampbell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GrahamCampbell/subscriptions","organizations_url":"https://api.github.com/users/GrahamCampbell/orgs","repos_url":"https://api.github.com/users/GrahamCampbell/repos","events_url":"https://api.github.com/users/GrahamCampbell/events{/privacy}","received_events_url":"https://api.github.com/users/GrahamCampbell/received_events","type":"User","site_admin":false},"created_at":"2015-08-22T15:10:04Z","updated_at":"2015-08-22T15:10:04Z","body":"https://github.com/StyleCI/StyleCI/tree/master/app is an example codebase that clearly shows that this stuff works."}}