laravel error" strtolower()期望参数1为字符串"?

时间:2016-12-26 10:19:30

标签: laravel laravel-5.3

我正在将json传递给laravel路由,如下所示,我运行此查询sql视图。

  

{" columns":[" fname"," lname"," mobile"]," offset" :" 1","限制":" 25",   "为了":[[" FNAME"" ASC"],[" L-NAME"" ASC"]] ,   "过滤器":[["两性"" ="" M"]]}

这是放在控制器中的功能,它将在路线上调用

public function fetch_contacts(Request $request){
    if($request->header('content-type') == 'application/json' && !empty($request->header('Device')) && !empty($request->header('UID'))){
          $query = DB::connection('mysql_freesubs')->table("contact_view")
              ->select($request->columns);

              if(!empty($request->filter))
                $query = $query->where($request->filter);

              if(!empty($request->offset))
                $query = $query->offset($request->offset);

              if(!empty($request->limit))
                $query = $query->limit($request->limit);

              if(!empty($request->order))
                $query = $query->orderBy($request->order);

              $contacts = $query->get();
              return $contacts;
}

我哪里错了?

1 个答案:

答案 0 :(得分:1)

您正在将多维数组传递给orderBy,请尝试以下方法:

$query = $query->orderBy($request->order[0][0], $request->order[0][1]);
$query = $query->orderBy($request->order[1][0], $request->order[1][1]);