2017 © Pedro Peláez
 

yii2-behaviors yii2-filesaver

Yii2 behavior for saving file in model

image

oleg-chulakov-studio/yii2-filesaver

Yii2 behavior for saving file in model

  • Wednesday, July 12, 2017
  • by Oleg Chulakov Studio
  • Repository
  • 1 Watchers
  • 1 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Yii2 behavior for file saving in model

Russian, (*1)

Install by composer

composer require oleg-chulakov-studio/yii2-filesaver, (*2)

Or add this code into require section of your composer.json and then call composer update in console

"oleg-chulakov-studio/yii2-filesaver": "*", (*3)

Usage

  • In model add behavior

php public function behaviors() { return [ .... [ 'class' => FileSaverBehavior::className(), 'group_type' => 'photo', 'in_attribute' => 'photoFile', 'out_attribute' => 'photo_id', 'del_attribute' => 'photoDel', 'allowedExtensions' => [ 'png', 'jpeg', 'jpg' ] ], ... ]; } - In model add fields ```php /** * @var UploadedFile /** $photoFile;, (*4)

/** * @var boolean /** $photoDel; ```, (*5)

Example usage

  • saving by url, (*6)

    $model = new TestModel();
    $model->photoFile = new \sem\filestorage\adapters\RemoteFile($url);
    $model->save();
    
    
  • saving by upload in form, (*7)

    $model = new TestModel();
    $model->photoFile = UploadedFile::getInstance($model, 'photoFile');
    $model->save();
    

The Versions

12/07 2017

dev-master

9999999-dev

Yii2 behavior for saving file in model

  Sources   Download

BSD 3-Clause

The Requires

 

by Lilit Babayan

12/07 2017

1.0.0

1.0.0.0

Yii2 behavior for saving file in model

  Sources   Download

BSD 3-Clause

The Requires

 

by Lilit Babayan