add Image and Upload helper classes
This commit is contained in:
@@ -3,22 +3,45 @@ namespace backend\models;
|
||||
|
||||
use yii\base\Model;
|
||||
use common\models\User;
|
||||
use common\models\Image;
|
||||
|
||||
class UploadForm extends Model{
|
||||
|
||||
|
||||
const SECRET= "aN6obLS2wMFzXw2VQBar";
|
||||
|
||||
public $image ;
|
||||
public $secret;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
* @formatter:off
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [['image',function ($attribute, $params) {}], ];
|
||||
return [
|
||||
|
||||
[['image'], 'image', 'mimeTypes' => 'image/jpeg, image/png', 'extensions'=>'jpg, png'],
|
||||
[['image'], 'required',],
|
||||
[['secret'], 'required'],
|
||||
[['secret'], 'validSecret'],
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
public function validSecret(){
|
||||
if ( $this->secret != self::SECRET ){
|
||||
$this->addError("secret","Invalid secret");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function save(){
|
||||
|
||||
$image = new Image();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user