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) {
$table->id();
$table->foreignId('user_id');
$table->foreignId('ticket_type_id');
$table->string('slug')->unique();
$table->string('title');
$table->text('body');
$table->string('email')->nullable();
$table->string('url')->nullable();
$table->boolean('locked')->default(false);
$table->unsignedInteger('visits')->default(0);
$table->timestamps();
});
Source: Laravel