Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // categorized array of results
- public function getCategResultsAttribute(){
- // question categories
- $categories = InsCategory::select('cat_id', 'name')
- ->get();
- $out = [];
- foreach ($categories as $cat) {
- $obj = [
- 'cat_name' => $cat->name,
- 'results' => []
- ];
- // questionnaires
- $chks = InsChecklist::where('cat_id', $cat->cat_id)
- ->select('chk_id', 'chk_desc')
- ->get();
- foreach($chks as $chk){
- $res = InsResult::where('chk_id', $chk->chk_id)
- ->select('res_id', 'head_id', 'chk_id', 'ispassed')
- ->where('head_id', $this->head_id)
- ->first();
- if ($res){
- array_push($obj['results'], [
- 'res_id' => $res->res_id,
- 'desc' => $chk->chk_desc,
- 'ispassed' => $res->ispassed
- ]);
- }
- }
- if (count($obj['results']) > 0)
- array_push($out, $obj);
- }
- return $out;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement