我执行时返回了一个简单的数组:
$this->forecast($value->id,$value->db_connection)
当我调用$reports::create($data)
它复制每一行时,我添加了一些逻辑来打印foreach中的$ data并且它永远不会返回重复项,当打印$ result对象时它有2个条目。
我知道哪里出错了?
public function store() // function to store report data in db
{
$reports = new Reports;
$companyData = new ClientSettings;
$settings = $companyData::all();
foreach ($settings as $value) {
$data = $this->forecast($value->id,$value->db_connection);
$result = $reports::create($data);
}
echo "Forecast generated";
}
答案 0 :(得分:0)
public function store() // function to store report data in db
{
$reports = new Reports;
$companyData = new ClientSettings;
$settings = $companyData::all();
foreach ($settings as $value) {
$data = $this->forecast($value->id,$value->db_connection);
$result = Reports::create($data);
}
echo "Forecast generated";
}