How to use UUID instead of a slug for ticket

  laravel, laravel-8

I am currently navigating to a ticket using the slug set by the title example blah-blah-blah and want to use uuid instead like 336c64de-5dcb-34bc-9511-a48242b9zzzb what is the best apprach to take for laravel 8 I am using Laravel Jetstream with Livewire stack.

Current model code:

public function getRouteKeyName()
    return 'slug';

public function setSlugAttribute($slug)
    $this->attributes['slug'] = Str::slug($slug);

public function path()
    return '/tickets/' . $this->slug;

Ticket Migration:

Schema::create('tickets', function (Blueprint $table) {

Source: Laravel

Leave a Reply