文章详情页的逻辑实现

文章详情页的逻辑实现

文章详情页路由的设置

//文章详情页
Route::get('/posts/{post}','\App\Http\Controllers\PostController@show');

控制器页面的实现

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Post;

class PostController extends Controller
{
    //列表页面
    ...

    //详情页面
    public function show(Post $post)
    {
        return  view('post/show',compact('post'));
    }

视图文件页面的实现

@extends("layout.main")
@section("content")
        <div class="col-sm-8 blog-main">
            <div class="blog-post">
                <div style="display:inline-flex">
                    <h2 class="blog-post-title">{{$post->title}}</h2>
                    <a style="margin: auto"  href="/posts/{{$post->id}}/edit">
                        <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
                    </a>
                    <a style="margin: auto"  href="/posts/{{$post->id}}/delete">
                        <span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
                    </a>
                </div>

                <p class="blog-post-meta">{{$post->created_at->toFormattedDateString()}}by <a href="#">Kassandra Ankunding2</a></p>

                <p>{{$post->content}}</p>
                <div>
                    <a href="/posts/{{$post->id}}}/zan" type="button" class="btn btn-primary btn-lg">赞</a>

                </div>
            </div>
...

Add a Comment

电子邮件地址不会被公开。 必填项已用*标注