Without using a resource controller, we can easily work with route model binding in Laravel. But it is a little bit tricky to use a resource controller with route model binding. Assume we are using uuid rather than id as the primary key. Now we want to work with uuid as like primary key with resource controller using route model binding. Now how we can use uuid as the primary key and solve the problem?

In this tutorial, I will show you how to work with route model binding with a resource controller. I will show you the Laravel route model binding uuid as an example. So if you are searching Laravel route model binding uuid like tutorial, then this example is going to help you.

To use uuid with route model binding, just use the following code in your model, then you have nothing to do.



namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Event extends Model
    use HasFactory;

    protected $fillable = [

    public function getRouteKeyName()
        return 'uuid';


Just return the "key" name which you want to bind in your route. 


Read also: How To Create Laravel Signed URL Middleware?



I have tried to discuss the clear concept of laravel signed routes. Now we know how to create laravel signed url. Hope this laravel signed url middleware example tutorial will help you

Category : #laravel

Tags : #laravel , #laravel routing