1. Go to this page and download the library: Download alesitom/hybrid-id-laravel 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/ */
alesitom / hybrid-id-laravel example snippets
use HybridId\Laravel\HasHybridId;
class User extends Model
{
use HasHybridId;
protected static string $idPrefix = 'usr';
}
use HybridId\IdGenerator;
class OrderService
{
public function __construct(
private readonly IdGenerator $idGenerator,
) {}
public function createOrder(): Order
{
return Order::create([
'id' => $this->idGenerator->generate('ord'),
'status' => 'pending',
]);
}
}
class Order extends Model
{
use HasHybridId;
protected static string $idPrefix = 'ord';
}
class Invoice extends Model
{
use HasHybridId;
protected static string $idPrefix = 'inv';
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.