@@ -3,8 +3,12 @@ Upload behavior for Yii 2
3
3
4
4
This behavior automatically uploads file and fills the specified attribute with a value of the name of the uploaded file.
5
5
6
- [ ![ Latest Stable Version] ( https://poser.pugx.org/mongosoft/yii2-upload-behavior/v/stable.png )] ( https://packagist.org/packages/mongosoft/yii2-upload-behavior )
7
- [ ![ Total Downloads] ( https://poser.pugx.org/mongosoft/yii2-upload-behavior/downloads.png )] ( https://packagist.org/packages/mongosoft/yii2-upload-behavior )
6
+ [ ![ Latest Version] ( https://img.shields.io/packagist/v/mongosoft/yii2-upload-behavior.svg?style=flat-square )] ( https://packagist.org/packages/mongosoft/yii2-upload-behavior )
7
+ [ ![ Software License] ( https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square )] ( LICENSE.md )
8
+ [ ![ Build Status] ( https://img.shields.io/travis/mongosoft/yii2-upload-behavior/master.svg?style=flat-square )] ( https://travis-ci.org/mongosoft/yii2-upload-behavior )
9
+ [ ![ Coverage Status] ( https://img.shields.io/scrutinizer/coverage/g/mongosoft/yii2-upload-behavior.svg?style=flat-square )] ( https://scrutinizer-ci.com/g/mongosoft/yii2-upload-behavior/code-structure )
10
+ [ ![ Quality Score] ( https://img.shields.io/scrutinizer/g/mongosoft/yii2-upload-behavior.svg?style=flat-square )] ( https://scrutinizer-ci.com/g/mongosoft/yii2-upload-behavior )
11
+ [ ![ Total Downloads] ( https://img.shields.io/packagist/dt/mongosoft/yii2-upload-behavior.svg?style=flat-square )] ( https://packagist.org/packages/mongosoft/yii2-upload-behavior )
8
12
9
13
Installation
10
14
------------
@@ -61,8 +65,8 @@ class Document extends ActiveRecord
61
65
'class' => UploadBehavior::className(),
62
66
'attribute' => 'file',
63
67
'scenarios' => ['insert', 'update'],
64
- 'path' => '@webroot/upload/docs/{category.id}/ ',
65
- 'url' => '@web/upload/docs/{category.id}/ ',
68
+ 'path' => '@webroot/upload/docs/{category.id}',
69
+ 'url' => '@web/upload/docs/{category.id}',
66
70
],
67
71
];
68
72
}
@@ -103,7 +107,7 @@ class User extends ActiveRecord
103
107
public function behaviors()
104
108
{
105
109
return [
106
- 'image' => [
110
+ [
107
111
'class' => UploadImageBehavior::className(),
108
112
'attribute' => 'image',
109
113
'scenarios' => ['insert', 'update'],
@@ -175,16 +179,15 @@ class Track extends ActiveRecord
175
179
{
176
180
return [
177
181
[
178
- 'class' => UploadBehavior::className(),
182
+ 'class' => UploadBehavior::className(),
179
183
'attribute' => 'image',
180
- 'scenarios' => [ 'default' ],
181
- 'path' => '@webroot/uploads/{artist.slug}/ ',
182
- 'url' => '@web/uploads/{artist.slug}/ ',
184
+ 'scenarios' => ['default'],
185
+ 'path' => '@webroot/uploads/{artist.slug}',
186
+ 'url' => '@web/uploads/{artist.slug}',
183
187
],
184
188
];
185
189
}
186
190
}
187
191
```
188
192
189
193
If related model attribute ` slug ` will change, you must change folders' names too, otherwise behavior will works not correctly.
190
-
0 commit comments