Model
error : "Array to string conversion (SQL: update
spent_timessetupdated_at= 2018-10-23 09:16:43,spent_time= 16,percentage= 70,task_category= testing whereid= 1) ◀"
public static function findOrCreate($plan_id, $data)
{
$fromDate = Carbon::now()->subDay()->startOfWeek();
$nowDate = Carbon::now()->today();
$spent_time = static::where('plan_id', $plan_id)->first();
if (is_null($spent_time)) {
return static::create($data);
}else{
$new_spent_time = SpentTime::first();
$task_category = $new_spent_time->task_category;
$new_spent_time->spent_time = $new_spent_time::where('task_category',$task_category)
->sum('daily_spent_time', $new_spent_time->daily_spent_time , $fromDate);
$new_spent_time['spent_time'] = $new_spent_time->spent_time + $spent_time->daily_spent_time;
$new_spent_time->percentage = $new_spent_time::where('task_category',$task_category)
->sum('daily_percentage', $new_spent_time->daily_percentage, $fromDate);
$new_spent_time['percentage'] = $new_spent_time->percentage + $spent_time->daily_percentage;
$new_spent_time->save();
return $spent_time->update($data);
}
}
and why is it only the first ID?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire