Reputation: 3386
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()
Upvotes: 1
Views: 2472
Reputation: 971
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
Upvotes: 0
Reputation: 9628
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();
Upvotes: 0
Reputation: 146239
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
.
Upvotes: 1
Reputation: 3455
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.
Upvotes: 0