对象无法转换为字符串 (laravel)

Object could not be converted to string (laravel)

我的问题是,为什么下面的方法不起作用?

    $questions = Question::where($queryatypes);

    $questions->get();

我收到以下错误:

Object of class Illuminate\Database\Eloquent\Builder could not be converted to string

我想你是在你的控制器上尝试这个 return 这个对象直接

use Illuminate\Http\Response;

public function controllerFunction(){
    $queryatypes = .....
    $questions = Question::where($queryatypes);
    $questions->get();
    return response($questions);
}

请检查答案

$questions = Question::where($queryatypes);
$questions = $questions->get();