instance slug with attribute id
Estimated reading time: 1 minuteinstance slug with attribute id
$article->save();
$articleID = $article->id;
$article->slug = $articleID.'-'.Str::slug($article->name, '-');
$article->save();
id or slug find attribute
Route::get('/courses/{param}', '[email protected]');
public function index($param)
{
$post = Post::where('id', $param)
->orWhere('slug', $param)
->firstOrFail();
}