Object could not be converted to string (laravel)

My question is, why does the following not work?

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

    $questions->get();

I'm getting the following Error:

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

Upvotes: 2

Views: 5744

Answers (2)

Hamelraj
Hamelraj

Reputation: 4826

Please check the answer

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

Upvotes: 1

nifCody
nifCody

Reputation: 2444

I think you are trying this on your controller and return this Objects directly

use Illuminate\Http\Response;

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

Upvotes: 1

Related Questions