无法将我的自定义查询插入col字段“ laraadmin”

时间:2019-04-30 15:41:23

标签: laravel laraadmin

在该ajax请求中,它正在发送绘图以将值插入表中,而我正在发送自定义查询而不是获取表

public function dtajax()
    {
         $users = User::all();

          $users =  DB::table('tc_users')
            ->join('users_tc_users','users_tc_users.tc_users_id', '=','tc_users.id')
            ->join('users','users.id', '=','users_tc_users.users_id') 
            ->leftJoin('cars','cars.users_id', '=','users.id')
            ->groupBy('users.id')
            ->select(DB::raw("users.id as id ,  users.name as name , users.email as email ,  users.Expiration_Date as Expiration_Date , users.phone_number as phone_number ,users.allowedcar as allowedcar ,COUNT(cars.id) as cars_count  "))
            ->get("users.id as id ,  users.name as name , users.email as email ,  users.Expiration_Date as Expiration_Date , users.phone_number as phone_number ,users.allowedcar as allowedcar,COUNT(cars.id) as cars_count ");

// print_r($users);
        $values = DB::table('users')->select($this->listing_cols)->whereNull('deleted_at');
        $out = Datatables::of($values)->make();
        // print_r($out);
        $datax = $out->getData();
        $datax->data = "";
        $datax->data = $users;

        $fields_popup = ModuleFields::getModuleFields('Users');
        $temp_field =array_push($fields_popup,'ttt');
        for($i=0; $i < count($datax->data); $i++) {
            $array = get_object_vars($datax->data[$i]);

                                    $val_array =     array_values ( $array );

                        //      print_r($val_array);
            for ($j=0; $j < count($this->listing_cols); $j++) { 
                $col = $this->listing_cols[$j];

                        $val_array[$i][$j] = ModuleFields::getFieldValue($fields_popup[$col], null, $val_array[$i][$j]);

$data->data[$i][$j]=$val_array[$j];
                if($fields_popup[$col] != null && starts_with($fields_popup[$col]->popup_vals, "@")) {

                }
                if($col == $this->view_col) {

                    $datax->data[$i][$j] = '<a href="'.url(config('laraadmin.adminRoute') . '/users/'.$datax->data[$i][0]).'">'.$datax->data[$i][$j].'</a>';
                }
                // else if($col == "author") {
                //    $data->data[$i][$j];
                // }
            }




        }
        $out->setData($datax);

        return $out;
    }
}

我遇到了这个错误:试图获取非对象的属性 从该行$val_array[$i][$j] = ModuleFields::getFieldValue($fields_popup[$col], null, $val_array[$i][$j]); 它应该返回已安排的表,但拒绝它作为数组

0 个答案:

没有答案