All Projects β†’ mlanin β†’ Laravel Hashids

mlanin / Laravel Hashids

Licence: mit
Integrate Hashids with Laravel. Automatic model binding and id resolving included!

Projects that are alternatives of or similar to Laravel Hashids

Laravel Hashids
A Hashids bridge for Laravel
Stars: ✭ 1,714 (+21325%)
Mutual labels:  hashids, laravel
Optimus
πŸ€– Id obfuscation based on Knuth's multiplicative hashing method for PHP.
Stars: ✭ 1,084 (+13450%)
Mutual labels:  hashids, laravel
Eloquent Hashids
On-the-fly hashids for Laravel Eloquent models. (🍰 Easy & ⚑ Fast)
Stars: ✭ 196 (+2350%)
Mutual labels:  hashids, laravel
Laravel Optimus
Transform your internal id's to obfuscated integers based on Knuth's integer hash. Laravel wrapper for the Optimus Library by Jens Segers with multiple connections support.
Stars: ✭ 119 (+1387.5%)
Mutual labels:  hashids, laravel
Laravel Hashslug
Package providing a trait to use Hashids on a model
Stars: ✭ 136 (+1600%)
Mutual labels:  hashids, laravel
Laravel Fakeid
Automatic model ID obfuscation in routes for Laravel
Stars: ✭ 161 (+1912.5%)
Mutual labels:  hashids, laravel
Laravel Hashid
Obfuscate your data by generating reversible, non-sequential, URL-safe identifiers.
Stars: ✭ 354 (+4325%)
Mutual labels:  hashids, laravel
Filament
The elegant TALL stack admin for Laravel artisans.
Stars: ✭ 900 (+11150%)
Mutual labels:  laravel
Laravel6 Frontend Boilerplate
A Vue.js Frontend starter project kit template/boilerplate with Laravel 6 Backend API support.
Stars: ✭ 26 (+225%)
Mutual labels:  laravel
Laravel Tools
路飞laravelε·₯ε…·
Stars: ✭ 24 (+200%)
Mutual labels:  laravel
Laravel Aws Sns
Laravel package for the AWS SNS Events
Stars: ✭ 24 (+200%)
Mutual labels:  laravel
Sentry Laravel
Laravel SDK for Sentry
Stars: ✭ 927 (+11487.5%)
Mutual labels:  laravel
Lighthouse Utils
An add-on to Lighthouse to auto-generate CRUD actions from types https://github.com/nuwave/lighthouse
Stars: ✭ 26 (+225%)
Mutual labels:  laravel
Laravel Mqtt Publish
A laravel mqtt publisher
Stars: ✭ 24 (+200%)
Mutual labels:  laravel
Laravel Relationships Data
Migrations, seeders and factories to get up and running with various relationship types data quickly
Stars: ✭ 27 (+237.5%)
Mutual labels:  laravel
Eloquent Filter
This simple package helps you filter Eloquent data using query filters.
Stars: ✭ 24 (+200%)
Mutual labels:  laravel
Hashids.rb
A small Ruby gem to generate YouTube-like hashes from one or many numbers. Use hashids when you do not want to expose your database ids to the user.
Stars: ✭ 842 (+10425%)
Mutual labels:  hashids
Laravel Restaurant Pos
Restaurant POS
Stars: ✭ 27 (+237.5%)
Mutual labels:  laravel
Socialite Mailru
MailRu OAuth2 Provider for Laravel Socialite
Stars: ✭ 25 (+212.5%)
Mutual labels:  laravel
Blade Migrations Laravel
An intelligent alternative version of Laravel 5/6 Database Migrations - uses raw-sql syntax, transactions, auto-rollback, UP-DOWN-UP testing
Stars: ✭ 25 (+212.5%)
Mutual labels:  laravel

Laravel-Hashids

Easily integrate Laravel with Hashids with full model support.

There are lots of packages for integrating Hashids with Laravel, but all of them just provide you with facade and add some syntax sugar.

But what about model binding and automatic id resolving? This package gives you all. All you have to do is just to install it!

Installation

PHP 5.4+ or HHVM 3.3+, Composer and Laravel 5.0+ are required.

To get the latest version of Laravel Laravel-Hashids, simply install it via composer.

$ composer require lanin/laravel-hashids

Once Laravel-Hashids is installed, you need to register the service provider. Open up config/app.php and add the following to the providers key.

Lanin\Laravel\Hashids\HashidsServiceProvider::class,

The last thing is to add \Lanin\Laravel\Hashids\UseHashidsRouter trait to your App\Http\Kernel. This will force Laravel to use package router to dispatch the route.

namespace App\Http;

class Kernel extends HttpKernel
{
    use \Lanin\Laravel\Hashids\UseHashidsRouter;
    
    ...
}

Also you can register HashidsFacade for easier access to the Hashids methods.

'Hashids' => Lanin\Laravel\Hashids\HashidsFacade::class,

Usage

You don't have to modify anything in your routes or html to make it run. If you are using model bindings and route resolving in html, everything will convert automatically.

Binding

After the installation, Router's method model that binds your placeholders ids to the models will be updated to automatically support hashids and convert them to the internal integer ids.

Routing

If you will pass hash id to the url it will be easily resolved into an associated model. But how replace ids in your html output? There are two ways. Everything depends on how you form your urls.

If you prefer form them by hands, package gives you the Blade helper method @hashids($id) that will convert your id to the hash string.

<a href="/posts/@hashids($post->id)">{{$post->title}}</a>

But this method is tedious. And I prefer using awesome Laravel feature that automatically extracts ids from models and inserts them into your urls. Example:

route('page.show', $page);
url('page', ['id' => $page]);

This methods were updated to handle Hashids too. They will automatically replace integer ids from your models to Hashids.

If for some reason you don't want to convert them, just implement \Lanin\Laravel\Hashids\DoNotUseHashids interface in your model.

Configuration

By default package will use your APP_KEY as a salt and 5 symbols length for the hash. If you want to overwrite it, publish hashids configs and edit config/hahshids.php

$ php artisan vendor:publish

Contributing

Please feel free to fork this package and contribute by submitting a pull request to enhance the functionalities.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].