{"action":"created","issue":{"url":"https://api.github.com/repos/laravel/framework/issues/16980","repository_url":"https://api.github.com/repos/laravel/framework","labels_url":"https://api.github.com/repos/laravel/framework/issues/16980/labels{/name}","comments_url":"https://api.github.com/repos/laravel/framework/issues/16980/comments","events_url":"https://api.github.com/repos/laravel/framework/issues/16980/events","html_url":"https://github.com/laravel/framework/issues/16980","id":197541692,"number":16980,"title":"[5.3] Unable to Fire Database Notifications for Archived/Soft Deleted Models","user":{"login":"rishi-ramawat","id":13311878,"avatar_url":"https://avatars.githubusercontent.com/u/13311878?v=3","gravatar_id":"","url":"https://api.github.com/users/rishi-ramawat","html_url":"https://github.com/rishi-ramawat","followers_url":"https://api.github.com/users/rishi-ramawat/followers","following_url":"https://api.github.com/users/rishi-ramawat/following{/other_user}","gists_url":"https://api.github.com/users/rishi-ramawat/gists{/gist_id}","starred_url":"https://api.github.com/users/rishi-ramawat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rishi-ramawat/subscriptions","organizations_url":"https://api.github.com/users/rishi-ramawat/orgs","repos_url":"https://api.github.com/users/rishi-ramawat/repos","events_url":"https://api.github.com/users/rishi-ramawat/events{/privacy}","received_events_url":"https://api.github.com/users/rishi-ramawat/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-12-26T06:18:41Z","updated_at":"2016-12-27T15:22:50Z","closed_at":"2016-12-27T15:22:50Z","body":"- Laravel Version: 5.3.22\r\n- PHP Version: 7.0.8\r\n- Database Driver & Version: MariaDB 10.1.18\r\n\r\n### Description:\r\nI have been trying to fire database notifications after an employee is archived. But the notification never gets saved into the notifications table of the database if the employee is archived.\r\n\r\n### Steps To Reproduce:\r\nMy model looks like this:\r\n```php\r\n<?php\r\n\r\nnamespace App\\Models;\r\n\r\nuse Illuminate\\Database\\Eloquent\\Model;\r\nuse Illuminate\\Database\\Eloquent\\SoftDeletes;\r\nuse Illuminate\\Notifications\\Notifiable;\r\n\r\nclass Employee extends Model {\r\n    use SoftDeletes, Notifiable;\r\n    // Other functions here...\r\n}\r\n```\r\nNow if I try this:\r\n```php\r\n$employee = Employee::find($employeeId);\r\nif (!$employee) {\r\n    // do something here\r\n}\r\ntry {\r\n    $employee->delete();\r\n    $employee->notify(new EmployeeArchived($employee));\r\n} catch (\\Exception $e) {\r\n    // do something here\r\n}\r\n```\r\nThe message returned by the `toDatabase()` function of the `EmployeeArchived` Notification class never gets saved in the database an No Exception is thrown too.\r\n\r\nWas there a specific reason for not allowing database notifications on soft deleted models???"},"comment":{"url":"https://api.github.com/repos/laravel/framework/issues/comments/269339592","html_url":"https://github.com/laravel/framework/issues/16980#issuecomment-269339592","issue_url":"https://api.github.com/repos/laravel/framework/issues/16980","id":269339592,"user":{"login":"themsaid","id":4332182,"avatar_url":"https://avatars.githubusercontent.com/u/4332182?v=3","gravatar_id":"","url":"https://api.github.com/users/themsaid","html_url":"https://github.com/themsaid","followers_url":"https://api.github.com/users/themsaid/followers","following_url":"https://api.github.com/users/themsaid/following{/other_user}","gists_url":"https://api.github.com/users/themsaid/gists{/gist_id}","starred_url":"https://api.github.com/users/themsaid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/themsaid/subscriptions","organizations_url":"https://api.github.com/users/themsaid/orgs","repos_url":"https://api.github.com/users/themsaid/repos","events_url":"https://api.github.com/users/themsaid/events{/privacy}","received_events_url":"https://api.github.com/users/themsaid/received_events","type":"User","site_admin":false},"created_at":"2016-12-27T15:22:50Z","updated_at":"2016-12-27T15:22:50Z","body":"It works with no problem, but I see you're passing the $employee to the notification class, not sure why you're doing this since the employee is already available as `$notifiable`.\r\n\r\nPlease refer to the forums for assistance, this is not a bug in the framework but something wrong with your code.\r\n\r\nClosing this, but please feel free to ping me if you need further explanation."}}
{"actor":{"display_login":"themsaid"}}