public function show($id, $num = 3) { if (Auth::user()->can('read-escalation-profiles')) { $data['title'] = "Escalation Profile"; $data['menu_actions'] = [Form::editItem(route('escalation_profiles.edit', $id), "Edit This Profile", Auth::user()->can('update-escalation-profiles'))]; $escalation_profile_events = DB::table('escalation_profile_event')->where('profile_id', $id)->get(); if (count($escalation_profile_events) > 0) { foreach ($escalation_profile_events as $key => $escalation_profile_event) { $data['escalation_profile_events']['delay_time'][$key] = $escalation_profile_event->delay_time; $data['escalation_profile_events']['event_id'][$key] = explode(",", $escalation_profile_event->event_id); $data['escalation_profile_events']['level_id'][$key] = $escalation_profile_event->level_id; $data['escalation_profile_events']['priority_id'][$key] = $escalation_profile_event->priority_id; $data['escalation_profile_events']['email_text'][$key] = $escalation_profile_event->email_text; } } else { $data['escalation_profile_events'] = null; } $data['escalation_profile'] = EscalationProfile::find($id); $data['escalation_events'] = EscalationEvent::all(); $data['levels'] = Level::all(); $data['priorities'] = Priority::all(); $data['delays'] = self::parseDelays(); $count = count($escalation_profile_events); $num = $num > 0 ? $num : 3; $data['rows'] = $count > 0 ? $count > $num ? $count : $num : $num; return view('escalation_profiles/show', $data); } else { return redirect()->back()->withErrors(['Access denied to esclation profiles show page']); } }