Question

I have the following function which activates a user after he registers via a url sent in email.

public function getActivate($code) {
    $user = User::where('code', '=', $code)->where('active', '=', 0);

    if($user->count()) {
        $user = $user->first();

        //Change user's active state 
        $user->active = 1;
        $user->code = '';

        if($user->save()) {
            return Redirect::route('home')
                    ->with('global', 'Activated! You can now sign in!');
        }
}
    return Redirect::route('home')
            ->with('global', 'We could not activate your account. Try again later.');
}

This was working, but now all i get is this error:

Symfony \ Component \ Debug \ Exception \ FatalErrorException
Call to undefined method stdClass::save()
Was it helpful?

Solution

It's a bug in the latest dev version. According to this answer. The bug is not present on any stable release. Change your composer.json's minimum-stability to stable and run a composer update. More on this thread on Github.

OTHER TIPS

Try to append get method at the end of your query, in order to return collection. When you have collection (which is Laravel collection of objects) you will be able to call method on that objects.

I had very similar symptoms, but in my case the problem was in the table schema definition:

        $table->integer('my_id')->unsigned();

Needed to be:

        $table->increments('my_id')->unsigned();

I Just had the same issue but i couldnt go stable as @The Alpha suggested as it was running React.js and it required a dev edition

so here is how i solve it

instead of

>>> $note->body = 'Some note for the card.';
=> "Some note for the card."
>>> $note->card_id = 2;
=> 2
>>> $note->save();
[Symfony\Component\Debug\Exception\FatalThrowableError]  
  Call to undefined method stdClass::save() 

here is what i did

>>> $note = new App\Note;
=> App\Note {#640}
>>> $note->body = 'Some note for the card.';
=> "Some note for the card."
>>> $note->card_id = 2;
=> 2
>>> $note->save();
=> true

and it worked ! Cheers

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top