i have next code:
$fixed_events = eventmain::find() ->select(["id", "title", "files"]) //->joinwith(['files']) //->with(['files']) ->asarray() ->all();
how can array "files" value, taking account, "files" modle's getter
public function getfiles() { return (json_decode($this->all_files, true)) ?: []; }
since files
not relation eventmain
table, guess easiest approach handle data , convert arrayhelper after coming db:
<?php use yii\helpers\arrayhelper; $models = eventmain::find()->select(['id', 'title'])->all(); $array = arrayhelper::toarray($models, [ 'app\models\eventmain' => ['id', 'title','files'] ]); var_dump($array); ?>
Comments
Post a Comment