Fix flight page errors and some naming fixes
This commit is contained in:
31
app/Models/Traits/HashIdTrait.php
Normal file
31
app/Models/Traits/HashIdTrait.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Traits;
|
||||
|
||||
use Hashids\Hashids;
|
||||
|
||||
trait HashIdTrait
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
* @throws \Hashids\HashidsException
|
||||
*/
|
||||
protected static function createNewHashId()
|
||||
{
|
||||
$hashids = new Hashids('', 12);
|
||||
$mt = str_replace('.', '', microtime(true));
|
||||
return $hashids->encode($mt);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register callbacks
|
||||
*/
|
||||
protected static function bootHashId()
|
||||
{
|
||||
static::creating(function ($model) {
|
||||
if (empty($model->id)) {
|
||||
$model->id = static::createNewHashId();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user