Yajra DataTable with attachment not working in laravel 5?

customer attitude to work

public function customer() { return $this->belongsTo('App\Customer','customerid'); } public function jobs(){ return $this->hasMany('App\Job','customerid'); } 

in the controller

 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(); } 
he throws the following error

 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) 

I am stuck on this issue from the 2nd day, please help me get out of this

+5
source share
2 answers

I just update the composer -> php composer.phar update Now it works fine Thanks

0
source

I think you missed the "order" in your query, try the following:

 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(); } 
0
source

Source: https://habr.com/ru/post/1243450/


All Articles