I tired ->get()->toJson() and it gives me the following error
Call to undefined method Illuminate\Database\Query\Builder::toJson()
toJson only works with Eloquent
e.g., Users::all()->toJson();
Otherwise if you are using the Query Builder then you can use the PHP json_encode() method.
E.g., json_encode(DB::table('users')->get());
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community