Secure your primary id often used in URL or shared in JSON

1.1 2021-10-24 06:01 UTC

This package is auto-updated.

Last update: 2024-05-05 04:29:02 UTC


Latest Version on Packagist Total Downloads


You can install the package via composer:

composer require saiashirwadinformatia/secure-ids

You can publish the config file with

php artisan vendor:publish --provider="SaiAshirwadInformatia\SecureIds\SecureIdsServiceProvider"

This is the contents of the published config file:

return [
    'models_directory' => 'Models',
    'model_namespace'  => 'App\\Models\\',
    'length'           => 13,


Load the configs of SecureIds by calling in your AppServiceProvider boot method

use SaiAshirwadInformatia\SecureIds\Facades\SecureIds;

class AppServiceProvider extends ServiceProvider
     * Register any application services.
     * @return void
    public function register()

Use trait HasSecureIds for the models you want to enable securing the id.

use SaiAshirwadInformatia\SecureIds\Models\Traits\HasSecureIds;

class User extends Authenticatable
    use HasApiTokens, HasFactory, Notifiable;
    // Add below Trait to enable securing id's
    use HasSecureIds;
    // ...


Please see CHANGELOG for more information on what has changed recently.



The MIT License (MIT). Please see License File for more information.