PHP code example of jvizcaya / encodid

1. Go to this page and download the library: Download jvizcaya/encodid 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/ */

    

jvizcaya / encodid example snippets


  $id = 347;
  $encode_id = encodeId($id); // 3kTMdQl1zu

namespace App;

use Illuminate\Database\Eloquent\Model;

class Post extends Model
{

    /**
     * Model Accessors.
     *
     *
     */
     public function getEncodeidAttribute()
     {
         return encodeId($this->id);
     }
}

  $post->encode_id;  // LkTM1Ql1Xa

  $ids = [14, 36, 89];
  $encode_ids = encodeIds($ids); // o2fXhVWKlu

  $encode_id = '3kTMdQl1zu';
  $id = decodeId($encode_id); // 347

  $encode_ids = 'o2fXhVWKlu';
  $ids = decodeIds($encode_ids); // [14, 36, 89]

  $encode_ids = [o2fXhVWKlu, uLkmPqwr1u, QP13YuOp7T];
  $ids = decodeArrayIds($encode_ids); // [42, 1935, 5456]

php artisan vendor:publish --provider="Jvizcaya\Encodid\EncodidServiceProvider"