客户与工作的关系
public function customer() {
return $this->belongsTo('App\Customer','customerid');
}
public function jobs(){
return $this->hasMany('App\Job','customerid');
}
控制器中的
protected function getJobs(){
$jobs = Job::Join('customer','jobs.customerid','=','customer.id')
->select(array('jobs.id','customer.firstname','customer.lastname','jobs.jobstatus','jobs.trialdate','jobs.deliverydate'));
return Datatables::of($jobs)
->addColumn('action', '<a class="btn btn-default btn-xs" data-toggle="tooltip" data-placement="top" title="Edit" href="{{ URL::to(\'updatejob/\'.$id) }}"><i class="fa fa-pencil"></i></a>')
->make();
}
SQLSTATE[42S22]: Column not found: 1054 Unknown column '0' in 'order clause' (SQL: select `jobs`.`id`, `customer`.`firstname`, `customer`.`lastname`, `jobs`.`jobstatus`, `jobs`.`trialdate`, `jobs`.`deliverydate` from `jobs` inner join `customer` on `jobs`.`customerid` = `customer`.`id` order by `0` asc limit 10 offset 0)
我从2天开始坚持这个问题请帮我从这个出来
答案 0 :(得分:1)
我认为你在查询中错过了“order by”,试试这个:
protected function getJobs(){
$jobs = Job::Join('customer','jobs.customerid','=','customer.id')
->select(array('jobs.id','customer.firstname','customer.lastname','jobs.jobstatus','jobs.trialdate','jobs.deliverydate'))
->orderBy('customer.lastname')->get();
return Datatables::of($jobs)
->addColumn('action', '<a class="btn btn-default btn-xs" data-toggle="tooltip" data-placement="top" title="Edit" href="{{ URL::to(\'updatejob/\'.$id) }}"><i class="fa fa-pencil"></i></a>')
->make();
}
答案 1 :(得分:1)
我只是更新作曲家 - &gt; php composer.phar更新 它的工作正常 谢谢