I use the same view to show one post and random post
routes
Route::get('posts/{id}', 'PostsController@show')->name('posts.show');
Route::get('get-random-post', 'PostsController@getRandomPost');
methods in PostsController
public function show($id) {
$post = Post::findOrFail($id);
return view('posts.show', compact('post'));
}
public function getRandomPost() {
$post = Post::inRandomOrder()
->where('is_published', 1)->first();
return redirect()->route('posts.show', ["id" => $post->id]);
}
but now I need to add a small difference between two views. How can I do that?
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2mH8OdP
via IFTTT
Aucun commentaire:
Enregistrer un commentaire