更新在 laravel 4 中出现错误的列
Updating a column giving error in laravel 4
我正在尝试更新 laravel 中名为 'is_shared' 的列,但出现错误。
我试过了。
public static function setShared($key, $status = true){
$input = ScorecardInputMeta::where("key", $key)->first();
if($input){
$input->is_shared = $status;
$input->save;
}
}//end function
Error:
{"error":{"type":"Symfony\Component\Debug\Exception\FatalErrorException","message":"Call
to a member function getResults() on
boolean","file":"D:\Projects\hbi_private\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php","line":2070}}
假设 ScorecardInputMeta
是一个 Eloquent Model
,尝试:
public static function setShared($key, $status = true)
{
// ->where(column, operator, value)
$input = ScorecardInputMeta::where('key', '=', $key)->first();
// check if input is not null or an object
if ($input) {
$input->is_shared = $status;
$input->save(); // changed from $input->save
}
}
我正在尝试更新 laravel 中名为 'is_shared' 的列,但出现错误。
我试过了。
public static function setShared($key, $status = true){
$input = ScorecardInputMeta::where("key", $key)->first();
if($input){
$input->is_shared = $status;
$input->save;
}
}//end function
Error: {"error":{"type":"Symfony\Component\Debug\Exception\FatalErrorException","message":"Call to a member function getResults() on boolean","file":"D:\Projects\hbi_private\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Model.php","line":2070}}
假设 ScorecardInputMeta
是一个 Eloquent Model
,尝试:
public static function setShared($key, $status = true)
{
// ->where(column, operator, value)
$input = ScorecardInputMeta::where('key', '=', $key)->first();
// check if input is not null or an object
if ($input) {
$input->is_shared = $status;
$input->save(); // changed from $input->save
}
}