Advertisement
arlendafitranto

ProjectModel_GNANM

Dec 18th, 2023
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.78 KB | Source Code | 0 0
  1. protected $appends = [
  2.         "c18", "c19", "c24", "c26", "c29", "c30", "c35", "c43", "c49",
  3.         "c25", "c36", "c37", "c38", "c44", "c45", "c50", "c51",
  4.         "step1", "step2", "step3", "step4", "step5", "step6", "step7",
  5.         "progress",
  6.     ];
  7.  
  8.     protected function progress(): Attribute
  9.     {
  10.         return Attribute::make(
  11.             get: fn () => $this->criterias->groupBy('step_id')->map(function($item, $key) {
  12.                 $count = 0;
  13.                 for ($i=0; $i < count($item); $i++) {
  14.                     if ($item[$i]['pivot']['doc_path'] != null) {
  15.                         $count += 1;
  16.                     }
  17.                 }
  18.                 return ["Step$key" => number_format($count / $item->count(), 1)];
  19.             })
  20.         );
  21.     }
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement