{"action":"created","issue":{"url":"https://api.github.com/repos/octobercms/october/issues/1372","labels_url":"https://api.github.com/repos/octobercms/october/issues/1372/labels{/name}","comments_url":"https://api.github.com/repos/octobercms/october/issues/1372/comments","events_url":"https://api.github.com/repos/octobercms/october/issues/1372/events","html_url":"https://github.com/octobercms/october/issues/1372","id":100979748,"number":1372,"title":"Attachment is not deleted when deleting the model","user":{"login":"voidshah","id":13226461,"avatar_url":"https://avatars.githubusercontent.com/u/13226461?v=3","gravatar_id":"","url":"https://api.github.com/users/voidshah","html_url":"https://github.com/voidshah","followers_url":"https://api.github.com/users/voidshah/followers","following_url":"https://api.github.com/users/voidshah/following{/other_user}","gists_url":"https://api.github.com/users/voidshah/gists{/gist_id}","starred_url":"https://api.github.com/users/voidshah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/voidshah/subscriptions","organizations_url":"https://api.github.com/users/voidshah/orgs","repos_url":"https://api.github.com/users/voidshah/repos","events_url":"https://api.github.com/users/voidshah/events{/privacy}","received_events_url":"https://api.github.com/users/voidshah/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/octobercms/october/labels/missing%20detail","name":"missing detail","color":"666666"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-08-14T10:02:36Z","updated_at":"2015-09-29T09:30:38Z","closed_at":null,"body":"I define relations as  single file attachment:\r\n```php\r\npublic $attachOne = [\r\n    'photo' => ['System\\Models\\File']\r\n];\r\n```\r\nor as multiple file attachments:\r\n```php\r\npublic $attachMany = [\r\n    'photos' => ['System\\Models\\File']\r\n];\r\n```\r\nWhen I delete record from the Model, record is removed, but attachment stay in system_files table and in /storage folder. But the related model must be deleted if the relationship is destroyed:\r\n'delete'  key is set to true by default, when relations defined as attachOne or attachMany in \\October\\Rain\\Database\\Model :\r\n```php\r\nprotected function getRelationDefaults($type)\r\n    {\r\n        switch ($type) {\r\n            case 'attachOne':\r\n            case 'attachMany':\r\n                return ['order' => 'sort_order', 'delete' => true];\r\n\r\n            default:\r\n                return [];\r\n        }\r\n    }\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/octobercms/october/issues/comments/144005509","html_url":"https://github.com/octobercms/october/issues/1372#issuecomment-144005509","issue_url":"https://api.github.com/repos/octobercms/october/issues/1372","id":144005509,"user":{"login":"ichakesachin30","id":9926066,"avatar_url":"https://avatars.githubusercontent.com/u/9926066?v=3","gravatar_id":"","url":"https://api.github.com/users/ichakesachin30","html_url":"https://github.com/ichakesachin30","followers_url":"https://api.github.com/users/ichakesachin30/followers","following_url":"https://api.github.com/users/ichakesachin30/following{/other_user}","gists_url":"https://api.github.com/users/ichakesachin30/gists{/gist_id}","starred_url":"https://api.github.com/users/ichakesachin30/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ichakesachin30/subscriptions","organizations_url":"https://api.github.com/users/ichakesachin30/orgs","repos_url":"https://api.github.com/users/ichakesachin30/repos","events_url":"https://api.github.com/users/ichakesachin30/events{/privacy}","received_events_url":"https://api.github.com/users/ichakesachin30/received_events","type":"User","site_admin":false},"created_at":"2015-09-29T09:30:38Z","updated_at":"2015-09-29T09:30:38Z","body":"Hi dme3us,\r\nThank you,\r\n\r\n// Deletes the database object only\r\n$model->photo()->delete(); \r\n\r\n=> it worked for mine.\r\n\r\n// Deletes database object and files\r\n$model->photo->delete();\r\n\r\nBut, I really want this option ?\r\n\r\n"}}