marriages as $spouse) { $usersMariageList[$spouse->pivot->id] = $user->name.' & '.$spouse->name; } $allMariageList = []; foreach (Couple::with('husband','wife')->get() as $couple) { $allMariageList[$couple->id] = $couple->husband->name.' & '.$couple->wife->name; } $malePersonList = User::where('gender_id', 1)->pluck('nickname', 'id'); $femalePersonList = User::where('gender_id', 2)->pluck('nickname', 'id'); return view('users.show', [ 'currentUser' => $user, 'usersMariageList' => $usersMariageList, 'malePersonList' => $malePersonList, 'femalePersonList' => $femalePersonList, 'allMariageList' => $allMariageList ]); } /** * Display the user's family chart. * * @param \App\User $user * @return \Illuminate\Http\Response */ public function chart(User $user) { $father = $user->father_id ? $user->father : null; $mother = $user->mother_id ? $user->mother : null; $fatherGrandpa = $father && $father->father_id ? $father->father : null; $fatherGrandma = $father && $father->mother_id ? $father->mother : null; $motherGrandpa = $mother && $mother->father_id ? $mother->father : null; $motherGrandma = $mother && $mother->mother_id ? $mother->mother : null; $childs = $user->childs; $colspan = $childs->count(); $colspan = $colspan < 4 ? 4 : $colspan; $siblings = $user->siblings(); return view('users.chart', compact('user', 'childs', 'father', 'mother', 'fatherGrandpa', 'fatherGrandma', 'motherGrandpa', 'motherGrandma', 'siblings', 'colspan')); } /** * Show the form for editing the specified resource. * * @param \App\User $user * @return \Illuminate\Http\Response */ public function edit(User $user) { // } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param \App\User $user * @return \Illuminate\Http\Response */ public function update(Request $request, User $user) { // } /** * Remove the specified resource from storage. * * @param \App\User $user * @return \Illuminate\Http\Response */ public function destroy(User $user) { // } }