PHP code example of tailflow / laravel-human-readable-keys

1. Go to this page and download the library: Download tailflow/laravel-human-readable-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/ */

    

tailflow / laravel-human-readable-keys example snippets


Schema::create('users', function (Blueprint $table) {
    $table->string('id');
    
    ...
});



namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Tailflow\HumanReadableKeys\Concerns\HasHumanReadableKey;

class User extends Model
{
    use HasHumanReadableKey;

   ...
}



namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Tailflow\HumanReadableKeys\Concerns\HasHumanReadableKey;

class User extends Model
{
    use HasHumanReadableKey;

   ...
   
    public function getKeyPrefix(): string
    {
        return 'account';
    }
}



namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Tailflow\HumanReadableKeys\Concerns\HasHumanReadableKey;

class User extends Model
{
    use HasHumanReadableKey;

   ...
   
    public function getKeyLength(): string
    {
        return 16;
    }
}