mirror of
https://github.com/nothingworksinc/ticketbeast.git
synced 2026-01-26 11:14:06 +00:00
91 - Integrating Hashids
This commit is contained in:
18
app/HashidsTicketCodeGenerator.php
Normal file
18
app/HashidsTicketCodeGenerator.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
class HashidsTicketCodeGenerator implements TicketCodeGenerator
|
||||
{
|
||||
private $hashids;
|
||||
|
||||
public function __construct($salt)
|
||||
{
|
||||
$this->hashids = new \Hashids\Hashids($salt, 6, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ');
|
||||
}
|
||||
|
||||
public function generateFor($ticket)
|
||||
{
|
||||
return $this->hashids->encode($ticket->id);
|
||||
}
|
||||
}
|
||||
@@ -4,5 +4,5 @@ namespace App;
|
||||
|
||||
interface TicketCodeGenerator
|
||||
{
|
||||
public function generate();
|
||||
public function generateFor($ticket);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user