/** * @return \Illuminate\View\View */ public function edit() { $id = Route::getCurrentRoute()->parameters()['id']; $data['lab'] = Labs::find($id); $data['docs'] = Docs::all(); $array = DocsLabs::where('lab_id', $id)->get(); $docs = ''; foreach ($array as $one) { $docs .= $one['doc_id'] . ', '; } $data['labs_docs'] = $docs; return view('labs.edit', compact('data')); }