Download the PHP package pmochine/laravel-nova-hashids without Composer

On this page you can find all versions of the php package pmochine/laravel-nova-hashids. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-nova-hashids

♺ Laravel Nova Hashids Card. Convert your ids.

This card for Laravel Nova converts ids on your dashboard. Enter a model id to get its hashid. Enter a hashid to get its model id. The card uses the connections of Laravel Hashids.

Latest Stable Version Total Downloads License Tests

Laravel Nova Hashids

Requirements

Package Version
PHP 8.2 or newer. Laravel 13 needs PHP 8.3 or newer.
Laravel 12 or 13
Laravel Nova 5
vinkla/hashids 13 for Laravel 12, 14 for Laravel 13

Hashids needs the PHP extension bcmath or gmp.

Version 2 of this package is for Nova 3 and Laravel 6 to 8. Version 2 gets no more updates. To install it, run composer require pmochine/laravel-nova-hashids:^2.3.

Installation

  1. Install the package with Composer. Composer also installs vinkla/hashids.

  2. Publish the Hashids configuration.

  3. Set your connections in config/hashids.php. Each connection has a salt, a length and an optional alphabet. For details, read the Laravel Hashids documentation. Do not use the connection name 0. The Hashids manager uses the default connection for this name, so the card does not show it.

  4. Add the card to a dashboard, for example in app/Nova/Dashboards/Main.php.

Usage

  1. If you have two or more connections, select a connection at the top of the card.
  2. Enter a hashid or a model id.
  3. Press Enter or click Convert.

The card shows the other value. If the hashid is not valid for the connection, the card shows an error. If you select a different connection after a conversion, the card converts the model id again. Until the new hashid arrives, the hashid field stays empty.

If a connection has a wrong configuration, for example a length that is not a number, the card shows an error. Laravel reports the exception to your log.

To copy the hashid, click Copy hashid. Browsers allow copying only on HTTPS pages and on localhost. On other pages, Nova shows an error message.

Select a connection for the card

Many applications use one Hashids connection for each model. Call connection() to set the first connection of the card. You can still select a different connection in the card.

If the connection does not exist in config/hashids.php, the card shows a warning and selects the default connection.

Show the hashid of a resource

You can add the card to the detail page of a Nova resource. On a detail page, the card converts the id of the resource at the start. Nova gives the id to the card. The card converts only ids that are whole numbers.

Translations

The card has English and German texts. It uses the locale of your application, app()->getLocale().

To add a different language, add the texts to two files in your application:

The German files of the package show all keys: lang/de.json.

Access

The card routes use Nova's Authenticate and Authorize middleware. Every user who can open Nova can use the converter. Nova checks this with the viewNova gate.

The canSee() method of a card hides the card. It does not protect the card routes.

Use your own hash algorithm

The card uses vinkla/hashids by default. To use a different algorithm, write a class that implements Pmochine\LaravelNovaHashids\Contracts\Converter. Then bind it in the register method of a service provider.

The contract has four methods. Model ids are strings of digits without leading zeros, so large ids keep all digits. The card accepts model ids with up to 20 digits and hashids with up to 1000 characters.

Method Returns
connections() The connection names for the select.
defaultConnection() The connection that the card selects first.
encode($connection, $modelId) The hashid. Return null for an id that the algorithm can not encode.
decode($connection, $hashId) One model id. Return null for a hashid that is not valid.

This example uses Sqids, the successor of Hashids. Install Sqids first.

Upgrade from version 2

Version 3 needs Nova 5, Laravel 12 or 13 and PHP 8.2. For all changes and the upgrade steps, read the changelog.

Development

The PHP tests use stubs for Nova, because Composer can install Nova only with a license. The card tests use Vitest. The build needs Node.js 24.

Commit the dist folder after each change to the card. Nova loads the card from dist. If dist does not match the sources, the CI workflow fails.

Security

If you discover any security related issues, please do not email me. I'm afraid 😱. [email protected]

Credits

Now comes the best part! 😍

Oh come on. You read everything?? If you liked it so far, hit the ⭐️ button to give me a 🤩 face.


All versions of laravel-nova-hashids with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/support Version ^12.0|^13.0
vinkla/hashids Version ^13.0|^14.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package pmochine/laravel-nova-hashids contains the following files

Loading the files please wait ...