當我更新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);
}
}
該插件,你更新?什麼是你的laravel版本 –
檢查'User'類的命名空間,並且'User'類是否擴展了Illuminate \ Database \ Eloquent \ Model'類? – mrabbani
請試用$ user = DB :: table('users') - > where('id',12) - > get();並檢查 –