PHP code example of ggmm-one / eloquent-hashids
1. Go to this page and download the library: Download ggmm-one/eloquent-hashids 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/ */
ggmm-one / eloquent-hashids example snippets
use Ggmm\Model\HasHashid;
class Car extends Model
{
use HasHashid;
}
# now your model has a hashid attribute
$car->hashid;
# to find the id from a hashid use decodeHashid
$car->decodeHashid('hashidhere');
use Ggmm\Model\HasHashid;
use Ggmm\Model\HashidRoutable
class Car extends Model
{
use HasHashid;
use HashidRoutable
}
# Now instead of a url like https://example.org/car/11/edit
# You will have a url like https://example.org/car/xLq/edit
use Hashids\Hashids;
class Car extends Model
{
use HasHashid;
public function __constructor()
{
$this->hashidGenerator = new Hashids('myhashsaltgoeshere');
}
}