我對 laravel tinker 部分很陌生,我有一個基于該模型的模型,我正在嘗試更新某些列值,但它引發了錯誤,請幫助我解決問題。
User::update(["status"=>"active"])->where ('id',1);
我得到的錯誤是
PHP FATAL error: class 'User' not found in psy shell code on line1
uj5u.com熱心網友回復:
嘗試User::update(["status"=>"active"])->where ('id',1)->first();
或更好:
$user = User::find(1);
$user->update(["status"=>"active"]);
“計劃”的來源一定是您的用戶模型中的錯誤。您是否private $with(['plans']);在模型中添加或類似的東西?也許您應該User.php在問題中發布您的模型。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/329919.html
