The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

Laravel Fakeid

propaganistas/laravel-fakeid image

Laravel Fakeid stats

Downloads
143.8K
Stars
198
Open Issues
0
Forks
13

View on GitHub →

Automatic ID obfuscation for Eloquent models.

Laravel FakeID

Enables automatic Eloquent model ID obfuscation in routes using Optimus.

Installation

  1. Run the Composer require command to install the package

    composer require propaganistas/laravel-fakeid
  2. The package will automatically register itself.

  3. Run the following artisan command to auto-initialize the package's settings

    php artisan fakeid:setup

Usage

Simply import the RoutesWithFakeIds trait into your model:

use Illuminate\Database\Eloquent\Model;
use Propaganistas\LaravelFakeId\RoutesWithFakeIds;
 
class MyModel extends Model
{
use RoutesWithFakeIds;
}

All routes generated for this particular model will expose a fake ID instead of the raw primary key. Moreover incoming requests containing those fake IDs are automatically converted back to a real ID. The obfuscation layer is therefore transparent and doesn't require you to rethink everything. Just use Laravel as you normally would.

Example

Assuming an Article model having a named show route.

routes/web.php:

Route::get('articles/{article}', 'ArticleController@show')->name('articles.show');

app/Article.php

use Illuminate\Database\Eloquent\Model;
use Propaganistas\LaravelFakeId\RoutesWithFakeIds;
 
class Article extends Model
{
use RoutesWithFakeIds;
}

A route to this specific endpoint can now be generated using Laravel's route() helper, and it will automatically contain a fake ID:

<a href="{{ route('articles.show', $article) }}"> {{ $article->name }} </a>

FAQ

Why didn't you implement Hashids instead of Optimus?

PERFORMANCE! Optimus is based on Knuth's multiplicative hashing method and proves to be quite faster than Hashids. It's even mentioned on Hashids' own website.

Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.


Propaganistas Laravel Fakeid Related Articles

UnitTest Attribute and More in Laravel 13.3.0 image

UnitTest Attribute and More in Laravel 13.3.0

Read article
Failover Queue Driver in Laravel 12.34 image

Failover Queue Driver in Laravel 12.34

Read article
Conditionally Fail Queue Jobs While Throttling Exceptions in Laravel 12.20 image

Conditionally Fail Queue Jobs While Throttling Exceptions in Laravel 12.20

Read article
Better defaults for your Laravel applications with Essentials image

Better defaults for your Laravel applications with Essentials

Read article
Catch Unintended HTTP Requests in Laravel Tests image

Catch Unintended HTTP Requests in Laravel Tests

Read article
Laravel Prompts Adds a Multi-line Textarea Input, Laravel 11.3 Released image

Laravel Prompts Adds a Multi-line Textarea Input, Laravel 11.3 Released

Read article
Acquaint Softtech logo

Acquaint Softtech

Acquaint Softtech offers AI-ready Laravel developers who onboard in 48 hours at $3000/Month with no lengthy sales process and a 100 percent money-back guarantee.

Acquaint Softtech
Laravel Cloud logo

Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Laravel Cloud
Curotec logo

Curotec

World class Laravel experts with GenAI dev skills. LATAM-based, embedded engineers that ship fast, communicate clearly, and elevate your product. No bloat, no BS.

Curotec
LoadForge logo

LoadForge

Scalable load testing for web apps & APIs. Simulate real-world traffic and identify breaking points and performance limits with powerful, scalable load tests designed for Laravel.

LoadForge
Blastup logo

Blastup

Blastup provides social media enhancement services including buying Instagram likes, followers, and views, with features like instant delivery and a variety of packages to suit different needs.

Blastup
Lucky Media logo

Lucky Media

Get Lucky Now - the ideal choice for Laravel Development, with over a decade of experience!

Lucky Media