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: 2021-11-24 06:15:13 UTC


README

Latest Version on Packagist Total Downloads

Installation

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,
];

Usage

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()
    {
        SecureIds::load();
    }

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;
    // ...

Changelog

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

Credits

License

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