更新插件会出错

时间:2017-08-03 05:43:28

标签: laravel phpstorm

当我更新Laravel插件时,如果我使用一些静态方法,例如User::find($id)它会显示警告:“非静态方法User :: find()不应该静态调用”,这非常糟糕!

示例:

namespace App\Http\Controllers\Web;

use App\Model\User;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use EasyWeChat\Foundation\Application;

class TestController extends Controller
{
    public function __construct(Application $wechat)
    {
        parent::__construct($wechat);
    }

    public function index(Request $request)
    {
        $user = User::find(12);
        dd($user);
    }
}

1 个答案:

答案 0 :(得分:0)

public function index(Request $request)
{
    $user = User::all()->find(12);
    dd($user);
}