1. Go to this page and download the library: Download toanld/ziggy library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
// app/Models/Post.php
class Post extends Model
{
public function getRouteKeyName()
{
return 'slug';
}
}
// app/Http/Controllers/PostController.php
class PostController
{
public function show(Request $request, Post $post)
{
return view('posts.show', ['post' => $post]);
}
}