現在,我在我的頁面上顯示視頻,點擊它後,我將其重定向到/ video {video}/view(其中{video}是視頻ID)。Laravel在不同的頁面上顯示不同的帖子
@foreach($videos as $video)
<div class="col-sm-4 feature">
<div class="panel">
<div class="panel-heading">
<h3 class="panel-title video_name">{{ $video->video_name }}</h3>
</div>
<div class="embed-responsive embed-responsive-16by9">
<iframe width="320" height="250" class="embed-responsive-item"
src="https://www.youtube.com/embed/{{ $video->video_url }}" allowfullscreen="allowfullscreen" mozallowfullscreen="mozallowfullscreen" msallowfullscreen="msallowfullscreen" oallowfullscreen="oallowfullscreen" webkitallowfullscreen="webkitallowfullscreen">
</iframe>
</div>
<div class="info">
<p>Posted by {{ $video->user->first_name }} on {{ $video->created_at }}</p>
<hr class="postInfo">
</div>
<p>{{ $video->description }} </p>
<a href="{{ route('view.video', [$video->id]) }}" class="btn btn-danger btn-block">Continue to video</a>
</div>
</div>
@endforeach
我已經在我的數據庫
Schema::create('posts', function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->text('body');
$table->integer('user_id');
$table->integer('video_id');
});
創造職位,但問題是我不知道我怎麼能顯示不同的影片不同的崗位,我越來越user_ID的,但我不能獲取video_id。
帖子創建功能:
public function postCreatePost(Request $request) {
$post = new Post();
$post->body = $request['body'];
$request->user()->posts()->save($post);
return redirect()->route('dashboard');
}