1. Go to this page and download the library: Download jamesmills/eloquent-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/ */
jamesmills / eloquent-uuid example snippets
namespace App;
use JamesMills\Uuid\HasUuidTrait;
class User extends Eloquent
{
use HasUuidTrait;
}
// ...
Schema::create('users', function (Blueprint $table) {
$table->primary('id');
$table->uuid('uuid')->unique(); // this will create a CHAR(36) field
$table->string('username', 32);
$table->string('password', 50);
// ...
});
Route::get('/user/{uuid}', function($uuid) {
$user = App\User::withUuid($uuid)->first();
if (! $user) {
// Do something else...
}
});
Route::delete('/users', function(Request $request) {
// Receive an array of UUIDs
$uuids = $request->input('uuids');
// Try to get the Users
$users = App\User::withUuids($uuids)->all();
// Handle the delete and return
$users->delete();
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.