{"action":"created","issue":{"url":"https://api.github.com/repos/sleeping-owl/admin/issues/130","labels_url":"https://api.github.com/repos/sleeping-owl/admin/issues/130/labels{/name}","comments_url":"https://api.github.com/repos/sleeping-owl/admin/issues/130/comments","events_url":"https://api.github.com/repos/sleeping-owl/admin/issues/130/events","html_url":"https://github.com/sleeping-owl/admin/issues/130","id":86030054,"number":130,"title":"Директория для сохранения изображений и валидация в модели","user":{"login":"ghost","id":10137,"avatar_url":"https://avatars.githubusercontent.com/u/10137?v=3","gravatar_id":"","url":"https://api.github.com/users/ghost","html_url":"https://github.com/ghost","followers_url":"https://api.github.com/users/ghost/followers","following_url":"https://api.github.com/users/ghost/following{/other_user}","gists_url":"https://api.github.com/users/ghost/gists{/gist_id}","starred_url":"https://api.github.com/users/ghost/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ghost/subscriptions","organizations_url":"https://api.github.com/users/ghost/orgs","repos_url":"https://api.github.com/users/ghost/repos","events_url":"https://api.github.com/users/ghost/events{/privacy}","received_events_url":"https://api.github.com/users/ghost/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-06-08T05:19:08Z","updated_at":"2015-08-07T12:35:53Z","closed_at":null,"body":"Привет!\r\nОчень нравится ваша админ-панель, перечитав всю документацию не могу понять как:\r\n1. Установить директорию для сохранения изображений в модели.\r\n2. Как использовать правила валидации из моделей.\r\n\r\nВ документации написано, что \"Если вам необходимо другое расположение файла - перемещайте его вручную в вашей модели.\", подскажите пожалуйста как это сделать?\r\n\r\nДля валидации использую https://github.com/dwightwatson/validating, правила задаются в массиве $rules, админка понимает только required. Есть ли другие правила?\r\n\r\nP.S. использую версию 3, большое спасибо!"},"comment":{"url":"https://api.github.com/repos/sleeping-owl/admin/issues/comments/128689384","html_url":"https://github.com/sleeping-owl/admin/issues/130#issuecomment-128689384","issue_url":"https://api.github.com/repos/sleeping-owl/admin/issues/130","id":128689384,"user":{"login":"EugeneTelyatnik","id":9371310,"avatar_url":"https://avatars.githubusercontent.com/u/9371310?v=3","gravatar_id":"","url":"https://api.github.com/users/EugeneTelyatnik","html_url":"https://github.com/EugeneTelyatnik","followers_url":"https://api.github.com/users/EugeneTelyatnik/followers","following_url":"https://api.github.com/users/EugeneTelyatnik/following{/other_user}","gists_url":"https://api.github.com/users/EugeneTelyatnik/gists{/gist_id}","starred_url":"https://api.github.com/users/EugeneTelyatnik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/EugeneTelyatnik/subscriptions","organizations_url":"https://api.github.com/users/EugeneTelyatnik/orgs","repos_url":"https://api.github.com/users/EugeneTelyatnik/repos","events_url":"https://api.github.com/users/EugeneTelyatnik/events{/privacy}","received_events_url":"https://api.github.com/users/EugeneTelyatnik/received_events","type":"User","site_admin":false},"created_at":"2015-08-07T12:35:53Z","updated_at":"2015-08-07T12:35:53Z","body":"Вот пример моей реализации:\r\n\r\n```php\r\nclass Background extends BaseModel\r\n{\r\n    protected $table = 'background';\r\n    public $imgPath = 'img/background/';\r\n\r\n    /**\r\n     * Image attribute accessor\r\n     * @param $value\r\n     * @return string\r\n     */\r\n    public function getImageAttribute($value)\r\n    {\r\n        //add full path to image\r\n        return $this->imgPath . $value;\r\n    }\r\n\r\n    /**\r\n     * Image attribute mutator\r\n     * @param $value\r\n     */\r\n    public function setImageAttribute($value)\r\n    {\r\n        //remove file\r\n        if (is_null($value)) {\r\n\r\n            $image = $this->imgPath . $this->attributes['image'];\r\n            if (File::exists($image)) {\r\n                File::delete($image);\r\n            }\r\n\r\n            //clean field\r\n            $this->attributes['image'] = null;\r\n\r\n        } else { //add file\r\n\r\n            //get name from path\r\n            $imageName = last(explode('/', $value));\r\n\r\n            //save in field only image name (without upload directory)\r\n            $this->attributes['image'] = $imageName;\r\n\r\n            //move image to a new directory\r\n            if (File::exists($value)) {\r\n                File::move($value, $this->imgPath . $imageName);\r\n            }\r\n        }\r\n    }\r\n}\r\n```"}}