当我更新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);
}
}
答案 0 :(得分:0)
public function index(Request $request)
{
$user = User::all()->find(12);
dd($user);
}