kr0lik/yii2-resource

Behaviour for resource store for Yii2

Installs: 920

Dependents: 1

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 1

Open Issues: 0

Type:yii2-extension

2.0.0 2020-05-09 18:04 UTC

This package is auto-updated.

Last update: 2024-04-10 03:03:22 UTC


README

Behaviour for resource store for Yii2

Installation

The preferred way to install this extension is through composer.

Either run

composer require --prefer-dist kr0lik/yii2-resource "*"

or add

"kr0lik/yii2-resource": "*"

to the require section of your composer.json file.

Usage

Add \kr0lik\resource\ResourceBehavior to your ActiveRecord

use yii\db\ActiveRecord;
use kr0lik\resource\ResourceBehavior;

class YourModel extends ActiveRecord
{
    ...
    public function behaviors()
    {
        return [
            'resource' => [
                'class' => ResourceBehavior::class,
                'attributes' => ['file'],
                'folder' => 'path/to/store/file/folder',
                'tmpFolder' => 'path/to/temp/file/folder'
                'originalFileNameAttribute' => 'attribute to store original file name. if null - no store'
            ]
        ];
    }
    ...
}

*folders are relative to the directory web.