PHP code example of foodticket / laravel-efficient-uuid

1. Go to this page and download the library: Download foodticket/laravel-efficient-uuid library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

foodticket / laravel-efficient-uuid example snippets


'providers' => [
    ...
    Dyrynda\Database\LaravelEfficientUuidServiceProvider::class,
],

Schema::create('posts', function (Blueprint $table) {
    $table->increments('id');
    $table->efficientUuid('uuid')->unique();
    $table->string('title');
    $table->text('body');
    $table->timestamps();
});



namespace App;

use Dyrynda\Database\Casts\EfficientUuid;
use Dyrynda\Database\Support\GeneratesUuid;
use Illuminate\Database\Eloquent\Model;

class Post extends Model
{
    use GeneratesUuid;

    protected $casts = [
        'uuid' => EfficientUuid::class,
    ];
}

use Dyrynda\Database\Rules\EfficientUuidExists;

public function update(Request $request, User $user)
{
    $request->validate([
        // Using the default column name
        'uuid' => [new EfficientUuidExists(Post::class)],

        // Using a custom column name
        'custom_uuid' => [new EfficientUuidExists(Post::class, 'custom_uuid')],
    ]);
}