'integer', 'budget' => 'string', ]; public static function boot() { parent::boot(); static::created(function ($data) { $activity = Activity::find($data->activity_id); $material = RequestMaterial::where("id", $data->material_id)->first(); $activity->rencana_biaya += floatval($material->price) * floatval($data->qty_planning); $activity->save(); }); static::deleted(function ($data) { $activity = Activity::where('id', $data->activity_id)->first(); $activity->rencana_biaya -= floatval($data->budget) * floatval($data->qty_planning); $activity->save(); }); } }