<?php
use App\Post; // Post model
// ...
class PostsController extends Controller
{
// ...
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
$post = Post::findOrFail($id);
return view('post', compact('post')); // pass in the $post variable to the view
}
}
<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::resource('/posts', 'PostsController');
{{ $post->body }}