app/Http/Controllers/Home/HomeController.php
/**
	 * Show the form for creating a new resource.
	 *
	 * @return Response
	 */
Show the form for creating a new resource.
@return Response
Show the form for creating a new resource . @return Response
public function message_info($id)
	{
		$message = Message::find($id);
		$message->face = User::find($message->user_id)->face;
		$cate = Category::find($message->category);
		$message->class_id = $cate->id;
		$message->class = $cate->name;
		$message->color = $cate->color;
		$comments = DB::table('comments')
                     ->select(DB::raw('comments.content,comments.user_id,comments.created_at,users.name,users.face,users.word,users.id as uid'))
                     ->leftJoin('users','comments.user_id','=','users.id')
                     ->where('comments.message_id','=',$id)
                     ->orderBy('comments.created_at','desc')
                     ->paginate(30);
		foreach ($comments as $key => $value) {
			$value->created_at = $this->t_time($value->created_at);
		}
		$data = [
			'message_info' => $message,
			'comments' => $comments
		];
		return view('home.message_info',$data);
	}
public function message_info ( $ id ) { $ message = Message :: find ( $ id ) ; $ message -> face = User :: find ( $ message -> user_id ) -> face ; $ cate = Category :: find ( $ message -> category ) ; $ message -> class_id = $ cate -> id ; $ message -> class = $ cate -> name ; $ message -> color = $ cate -> color ; $ comments = DB :: table ( 'comments' ) -> select ( DB :: raw ( 'comments.content,comments.user_id,comments.created_at,users.name,users.face,users.word,users.id as uid' ) ) -> leftJoin ( 'users' , 'comments.user_id' , '=' , 'users.id' ) -> where ( 'comments.message_id' , '=' , $ id ) -> orderBy ( 'comments.created_at' , 'desc' ) -> paginate ( 30 ) ; foreach ( $ comments as $ key => $ value ) { $ value -> created_at = $ this -> t_time ( $ value -> created_at ) ; } $ data = [ 'message_info' => $ message , 'comments' => $ comments ] ; return view ( 'home.message_info' , $ data ) ; }
Show the form for creating a new resource.
Show the form for creating a new resource .
//所属评论 // comments表中属于这个id的评论数据 // return view('home.message_info')->withmessage_info($message)->withcomments($comments);