Support the ongoing development of Laravel.io →
Input Database Eloquent
Last updated 2 years ago.
0

Not sure what you are after but see if this post will help you any. http://laravel.io/forum/05-09-2015-clean-way-of-combining-an-array-for-a-listbox

0

im trying to get the column "user_no", "firstname", "lastname"

0

I use the setVisible trick. Not sure if it's a good idea

public function getemployee(){
        $id = $_POST['id'];
        $employees = mot_users::where("branch_no", $id)->get();
        foreach ($employees as $employee) {
            $employee->setVisible(['user_no', 'firstname', 'lastname']);
        }
        return response()->json(['success' => true, 'employees' => $employees]);
    }
0

I instead use this

$employees = mot_users::where("branch_no", $id)
    ->select(array('user_no', 'lastname', 'firstname'))
    ->get()->toArray();
 return response()->json(['success' => true, 'employees' => $employees]);

yet now im having a problem on fetching the json data response as it returns me

[Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object]

any ideas how to fetch that [object object] stuff?

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.