Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

thusfar's avatar

Call to undefined method Illuminate\Database\Query\Builder::save()

So I'm using Spark and I want to retrieve a user so I do the following but I get the error

Call to undefined method Illuminate\Database\Query\Builder::save()

These are classes I include:

use Illuminate\Http\Request;
use App\Http\Requests;
use Laravel\Spark\Spark;
use Twocheckout;
use Twocheckout_Sale;
use Twocheckout_Error;
use Laravel\Spark\Subscription;
use Laravel\Spark\LocalInvoice;
use App\User;

Here is how I retrieve User model.

        $user = User::all()->where('email', $data['user_email'])->first();

I cannot do this.

        $user = User::where('email', $data['user_email'])->first();

It has to have ::all()

And then when I try to save

$user->save();

PhpStorm says the method doesnt exist.

What am I doing wrong???

0 likes
4 replies
christian_H's avatar

What do you mean by "It has to have ::all()"? Does it throw an exception if you don't include that or just not return any results?

jlrdw's avatar

Look at the docs carefully, an edit in orm is save, but QB is update.

rsands's avatar

Why do you have to query using all() ? if you d($user); is it a collection or an instance of Builder?

thusfar's avatar

Well it seems like I dont have. But when I dont then Phpstorm doesnt offer "where" in autocomplete. But it seems, it works without all().

Please or to participate in this conversation.