php - if more than 2 column selected in list -


i have eloquent model query

public function getemployee(){     $id = $_post['id'];     $employees = mot_users::where("branch_no", $id)->lists('user_no', 'lastname', 'firstname');     return response()->json(['success' => true, 'employees' => $employees]); } 

the problem "->lists();" can handle 2 columns sent json response (seen through console, 2 selected columns out of 3 sent). how can send 3 columns or more 2 columns in "->list()" or there alternative eloquent model query other using "->list()" if impossible?

to this, a

$employees = mot_users::where("branch_no", $id)->get(array('user_no','lastname','firstname'))->toarray(); 

that should trick.

note if model object has relationship , column relationship isn't part of try ->get can't error.

note 2 here you're using ol' $_post, should consider using proper request object seen in doc.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -