无法将Illuminate \ Database \ Eloquent \ Builder类的对象转换为字符串 [英] Object of class Illuminate\Database\Eloquent\Builder could not be converted to string
本文介绍了无法将Illuminate \ Database \ Eloquent \ Builder类的对象转换为字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个代码.一切正常-从DB获取数据,但是我无法返回.我正在使用jQuery发布它.
I have this code. Everything works fine - it gets data from DB but i cannot be returned. I'm posting it using jQuery.
Route::post('get/images', function(){
$images = App\Images::where('realisation_id',Request::get('id'));
return $images;
});
它返回
Illuminate \ Database \ Eloquent \ Builder类的对象无法转换为字符串
Object of class Illuminate\Database\Eloquent\Builder could not be converted to string
推荐答案
我很愚蠢!
Route::post('get/images', function(){
$images = App\Images::where('realisation_id',Request::get('id'))->get();
return $images->toJson();
});
一切都很棒!
这篇关于无法将Illuminate \ Database \ Eloquent \ Builder类的对象转换为字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文