/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { // $pet = PetRelations::find($id); if ($pet->owner_id !== Auth::id() && !$pet->is_public) { abort(403); } // return PetRelations::find($id); // print_r(Config::get('db_const.DB_PET_STATUS_VALUE')[1]); if ($pet->owner_id === Auth::id()) { $pet->owner_name = Auth::user()->name; } else { $pet_owner = User::find($pet->owner_id); if ($pet_owner->is_public) { $pet->owner_name = $pet_owner->name; } else { $pet->owner_name = 'Secret'; } } $pet->status_value = Config::get('db_const.DB_PET_STATUS_VALUE')[$pet->status]; return view('pets/show')->with('pet', $pet); }
public function owner() { return User::find($this->created_user_id); }