Php 如何更新数据库表中的值,laravel?

Php 如何更新数据库表中的值,laravel?,php,laravel,laravel-4,eloquent,Php,Laravel,Laravel 4,Eloquent,我正在尝试更新laravel4中数据库中的值。这有点像一个案例,我在数据库中只有一个条目,其中有一个会话id。它用于对facebook进行身份验证 这就是模型: <?php use Illuminate\Auth\UserInterface; use Illuminate\Auth\Reminders\RemindableInterface; class Accesstoken extends Eloquent { public static function cre

我正在尝试更新laravel4中数据库中的值。这有点像一个案例,我在数据库中只有一个条目,其中有一个会话id。它用于对facebook进行身份验证

这就是模型:

<?php

use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableInterface;

    class Accesstoken extends Eloquent {

    public static function createpost($token)
    {
        $accesstoken = new Accesstoken;
        $accesstoken->accesstoken = $token;
        $accesstoken->save();
    }

    public static function update($token)
    {
        $accesstoken = Accesstoken::find(1);
        $accesstoken->accesstoken = $token;
        $accesstoken->save();
    }
}
我得到以下错误,为什么

无法在类Accesstoken中将非静态方法Illumb\Database\Eloquent\Model::update()设为静态方法

Eloquent中已存在update()方法。试试像这样的东西

<?php

use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableInterface;

    class Accesstoken extends Eloquent {

    public static function createpost($token)
    {
        $accesstoken = new Accesstoken;
        $accesstoken->accesstoken = $token;
        $accesstoken->save();
    }

    public static function updateToken($token)
    {
        $accesstoken = Accesstoken::find(1);
        $accesstoken->accesstoken = $token;
        $accesstoken->save();
    }
}

Eloquent\Model
已经实现了一个非静态的方法
公共函数更新(array$attributes=array())
<?php

use Illuminate\Auth\UserInterface;
use Illuminate\Auth\Reminders\RemindableInterface;

    class Accesstoken extends Eloquent {

    public static function createpost($token)
    {
        $accesstoken = new Accesstoken;
        $accesstoken->accesstoken = $token;
        $accesstoken->save();
    }

    public static function updateToken($token)
    {
        $accesstoken = Accesstoken::find(1);
        $accesstoken->accesstoken = $token;
        $accesstoken->save();
    }
}
Accesstoken::updateToken($access_token);