Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Laravel-开发版本导致调用未定义的方法stdClass_Laravel - Fatal编程技术网

Laravel-开发版本导致调用未定义的方法stdClass

Laravel-开发版本导致调用未定义的方法stdClass,laravel,Laravel,我有以下功能,激活用户后,他通过电子邮件发送的url注册 public function getActivate($code) { $user = User::where('code', '=', $code)->where('active', '=', 0); if($user->count()) { $user = $user->first(); //Change user's active state

我有以下功能,激活用户后,他通过电子邮件发送的url注册

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.');
}
这是可行的,但现在我得到的只是一个错误:

Symfony \ Component \ Debug \ Exception \ FatalErrorException
Call to undefined method stdClass::save()

尝试在查询结束时附加get方法,以返回集合。当您拥有collection(对象的Laravel集合)时,您将能够对该对象调用方法。

这是最新
dev
版本中的一个bug。根据。在任何稳定版本中都不存在该缺陷。将
composer.json
最小稳定性
更改为
稳定
,然后运行composer更新。关于Github的更多信息

我有非常相似的症状,但在我的案例中,问题在于表架构定义:

        $table->integer('my_id')->unsigned();
需要:

        $table->increments('my_id')->unsigned();
我也有同样的问题 但是我不能像@thealpha建议的那样保持稳定,因为它正在运行React.js,并且需要一个dev版本

下面是我如何解决它的

而不是

>>> $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() 
这就是我所做的

>>> $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

成功了!Cheers

它不工作,并在$user->count()函数上产生问题。这是最新的
dev
版本吗?确切的版本是什么?您最近更新了Laravel吗?如果是,则回滚,这是最新
dev
版本中的bug。根据。我最近更新了作曲家。我应该运行composer self-update-rollback吗?就是这样,这是
dev
版本上的一个bug。太好了!!谢谢Sheikh,它现在正在工作,但它仍然显示“向get函数前进”