1. Go to this page and download the library: Download jdavidbakr/ulidmodelroutes 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/ */
jdavidbakr / ulidmodelroutes example snippets
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
Schema::table('posts', function (Blueprint $table) {
$table->ulid('ulid')->nullable()->unique();
});
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
Schema::table('posts', function (Blueprint $table) {
$table->uuid('uuid')->nullable()->unique();
});
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use jdavidbakr\UlidModelRoutes\HasUlidRouteKey;
class Post extends Model
{
use HasUlidRouteKey;
}
use App\Models\Post;
use Illuminate\Support\Facades\Route;
Route::get('/posts/{post}', function (Post $post) {
return $post;
});