1. Go to this page and download the library: Download oneduo/laravel-human-keys 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/ */
oneduo / laravel-human-keys example snippets
return [
/*
|--------------------------------------------------------------------------
| Generator
|--------------------------------------------------------------------------
|
| Used to define the generator to use for generating model keys.
|
| Supported:
| - ksuid (abc_p6UEyCc8D8ecLijAI5zVwOTP3D0)
| - snowflake (abc_1537200202186752)
|
| Default: ksuid
|
| Note: You may define your own generator by implementing the contract
| Oneduo\LaravelHumanKeys\Contracts\Generator and passing
| the class name to the generator config option.
|
| See the example below:
| 'generator' => \App\Services\MyGenerator::class
*/
'generator' => 'ksuid',
];
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Oneduo\LaravelHumanKeys\Concerns\HasHumanKey;
class Post extends Model
{
use HasHumanKey;
}
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Oneduo\LaravelHumanKeys\Concerns\HasHumanKey;
class Post extends Model
{
use HasHumanKey;
public static function getKeyPrefix() : string {
// prefix without _ underscore as it gets added by the generator
return 'post_prefix'
}
}