This package is not installable via Composer 1.x, please make sure you upgrade to Composer 2+. Read more about our Composer 1.x deprecation policy.

A Laravel UUID Package

v1.0.1 2021-04-17 21:46 UTC

This package is auto-updated.

Last update: 2021-10-13 11:28:44 UTC


A Laravel package to add uuid to models

Table of contents


composer require salmanzafar/laravel-model-uuid

Configuration (optional)

Publishing service provider

php artisan vendor:publish --provider="Salman\LaravelModelUUID\LaravelModelUUISServiceProvider::class"

Enable the package (Optional)

This package implements Laravel auto-discovery feature. After you install it the package provider and facade are added automatically for laravel >= 5.5.

Model Uuid

There are many cases where we want to use uuid as primray key in our model now that is also easier you can use uuid as pk in a jiffy

namespace App;

use \Vault\LaravelVaultUUID\Concerns\UsesUuid;
use Illuminate\Database\Eloquent\Model;

class Car extends Model
   use UsesUuid;

By just using UsesUuid in your model now you have uuid as pk in your model. don't forget to make changes in migration


use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateCarsTable extends Migration
     * Run the migrations.
     * @return void
    public function up()
        Schema::create('cars', function (Blueprint $table) {

     * Reverse the migrations.
     * @return void
    public function down()

Publishing files

The below command will publish all related files inside App\Concerns folder

php artisan publish:uuid-trait