Laravel:从空值创建默认对象插入时

时间:2017-09-10 12:36:37

标签: php laravel laravel-5

我在Creating default object from empty value上遇到$analyses->result = 1.0;问题我在我的数据库中检查了所有这些列。

  $analysis = new Analysis;
  $analysis->psubid = '1';
  $analysis->subjectid = '1';
  $analyses->result = 1.0;
  $analyses->rtd = 2.0;
  $analyses->save();
  $Analysis = Analysis::all();
  return $Analysis;

1 个答案:

答案 0 :(得分:0)

您正在使用$analysis名称启动变量,并在某些语句中使用$analyses。为所有

使用相同的名称
$analysis = new Analysis;
  $analysis->psubid = '1';
  $analysis->subjectid = '1';
  $analysis->result = 1.0;
  $analysis->rtd = 2.0;
  $analysis->save();
  $Analysis = Analysis::all();
  return $Analysis;