Model validation


I have one model name Agency_bill_book

and controller AController

I am saving all details on one click my action for create is below…

public function actionCreate(){

        $model = new AgencyBillBook();  

        $model->scenario = AgencyBillBook::SCENARIO_CREATE;


        // i am taking only month and sundays from post, rest things from database

        $dates=$request->post('date1');//for month

        $dd=$request->post('date');//for dates date is an array

        $prices=$request->post('price');//price is also an array



        $alldate=Yii::$app->mycomponent->calsunday();//this will calculate all sundays in selected month



        foreach ($alldate as $date){

            $agency=$model->get_all_agencies($date);//this will get all agencies on particulat date



                foreach ($agency as $key=> $val) {



                    $model->isNewRecord = TRUE; 










                    $model->created_on=  date('Y-m-d H:i:s');

                   if($model->validate() && $model->save()){



                       return $this->render('welcome',['error'=>$model->errors]);









And my scenario for is this

 public function scenarios()


    $scenarios = parent::scenarios();

    $scenarios[self::SCENARIO_CREATE] = [[['issue_date'],'unique'], [['issue_date'], 'string', 'max' => 32],];

    return $scenarios;


     this is not working for me...

     I am getting this error 

 PHP Notice – yii\base\ErrorException

Array to string conversion

    1. in /var/www/html/advanced/vendor/yiisoft/yii2/validators/Validator.php at line 234

         * @param \yii\base\Model $model the data model being validated

         * @param array|null $attributes the list of attributes to be validated.

         * Note that if an attribute is not associated with the validator,

         * it will be ignored.

         * If this parameter is null, every attribute listed in [[attributes]] will be validated.


        public function validateAttributes($model, $attributes = null)


            if (is_array($attributes)) {

                $attributes = array_intersect($this->attributes, $attributes);

            } else {

                $attributes = $this->attributes;


            foreach ($attributes as $attribute) {

                $skip = $this->skipOnError && $model->hasErrors($attribute)

                    || $this->skipOnEmpty && $this->isEmpty($model->$attribute);

                if (!$skip) {

                    if ($this->when === null || call_user_func($this->when, $model, $attribute)) {

                        $this->validateAttribute($model, $attribute);

Please help me…or suggest me better way to do this…