Controller:
Код: Выделить всё
$model = new DeleteK();
$model->load(Yii::$app->request->bodyParams, '');
$k_out = $this->geo->findOne(intval($model->id));
// $this->geo->patch = null;
$this->geo->scenario = 'delete_by_admin';
if($model->validate() AND $k_out['id'] AND $this->geo->deleteAll(['id'=>$k_out['id']])){
return json_encode(['deleted'=>'ok']);
}
Код: Выделить всё
return [
TimestampBehavior::class,
[
'class' => UploadImageBehavior::class,
'attribute' => 'patch',
'unlinkOnDelete' => true,
'instanceByName' => true,
'scenarios' => ['insert_by_user', 'admin_edit_photo', 'delete_by_admin'],
'path' => Yii::getAlias('@frontend').'/web/uploads/{id}',
'url' => '/images/uploads/{id}',
'thumbs' => [
'preview' => ['width' => 400, 'quality' => 100 /* 'height' => 200 */],
'thumb' => ['width' => 100, 'quality' => 100],
'news_thumb' => ['width' => 50, 'bg_color' => '000'],
],
],
];