Browse Source

Merge pull request 'update upload 2023-10-16' (#209) from staging into master

Reviewed-on: ordo/adw-backend#209
pull/3/head
farhantock 1 year ago
parent
commit
0c21400397
  1. 9
      app/Http/Controllers/ActivityController.php
  2. 34
      app/Models/Role.php

9
app/Http/Controllers/ActivityController.php

@ -175,6 +175,7 @@ class ActivityController extends Controller
}else{ }else{
$data = Activity::select('id', 'parent_id', 'name', 'actual_end')->where('parent_id', $id)->get(); $data = Activity::select('id', 'parent_id', 'name', 'actual_end')->where('parent_id', $id)->get();
} }
$parent = Activity::findOrFail($id);
$dataFinal=[]; $dataFinal=[];
foreach ($data as $val) { foreach ($data as $val) {
$activity = $this->getchildActivityForActual($val->id, $params); $activity = $this->getchildActivityForActual($val->id, $params);
@ -187,11 +188,19 @@ class ActivityController extends Controller
return isset($item['actual_start']); return isset($item['actual_start']);
}), 'actual_start'); }), 'actual_start');
$returnActualStartOrEnd = count($actualStartValues) == count($dataFinal) ? min($actualStartValues) : null; $returnActualStartOrEnd = count($actualStartValues) == count($dataFinal) ? min($actualStartValues) : null;
if (isset($parent)) {
$parent->actual_start = $returnActualStartOrEnd;
$parent->save();
}
}else{ }else{
$actualEndValues = array_column(array_filter($dataFinal, function($item) { $actualEndValues = array_column(array_filter($dataFinal, function($item) {
return isset($item['actual_end']); return isset($item['actual_end']);
}), 'actual_end'); }), 'actual_end');
$returnActualStartOrEnd = count($actualEndValues) == count($dataFinal) ? max($actualEndValues) : null; $returnActualStartOrEnd = count($actualEndValues) == count($dataFinal) ? max($actualEndValues) : null;
if (isset($parent)) {
$parent->actual_end = $returnActualStartOrEnd;
$parent->save();
}
} }
// return json_encode(["min"=>$minActualStart, "max"=>$maxActualStart]); // return json_encode(["min"=>$minActualStart, "max"=>$maxActualStart]);

34
app/Models/Role.php

@ -1,17 +1,17 @@
<?php <?php
namespace App\Models; namespace App\Models;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
class Role extends Model class Role extends Model
{ {
protected $table = 'm_roles'; protected $table = 'm_roles';
const CREATED_AT = 'created_at'; const CREATED_AT = 'created_at';
const UPDATED_AT = 'updated_at'; const UPDATED_AT = 'updated_at';
protected $fillable = [ protected $fillable = [
'name', 'description', 'created_at', 'created_by', 'updated_at', 'updated_by' 'name', 'description', 'created_at', 'created_by', 'updated_at', 'updated_by'
]; ];
} }

Loading…
Cancel
Save