Browse Source

Merge pull request 'Fix lag' (#110) from dev-wahyu into staging

Reviewed-on: ordo/adw-backend#110
pull/3/head
ibnu 1 year ago
parent
commit
c136ce96d1
  1. 12
      app/Http/Controllers/ActivityController.php

12
app/Http/Controllers/ActivityController.php

@ -14,6 +14,7 @@ use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use DateTime;
class ActivityController extends Controller
{
@ -250,6 +251,17 @@ class ActivityController extends Controller
$updateBobot = true;
if(!$data = Activity::find($id))
return response()->json(['status'=>'failed', 'action'=>'error','message'=>'Data not found!','code'=> 404], 404);
$link = Link::where('t_activity_id', $data->id)->get();
if ($link) {
foreach ($link as $linkData) {
$predecessor = Activity::find($linkData->s_activity_id);
$start = new DateTime($data->start_date);
$end = new DateTime($predecessor->end_date);
$lag = $start->diff($end)->format('%a');
$linkData->lag = $lag;
$linkData->save();
}
}
$dataUpdate = $request->all();
$dataUpdate['name'] = $request->text;

Loading…
Cancel
Save