where('hashed_id', '...')) are optimized with composite indexes or full-text search if needed.composer.json for exact versions). Verify compatibility with your PHP version (8.1+ recommended).hashed_id column./users/{hashed_id}) while preserving internal DB IDs./products/aB3#xyz) without exposing DB IDs.hashed_id column (e.g., string or varchar).where('id', $userId)) to plan replacements.hashed_id column to target tables (e.g., via migration):
Schema::table('users', function (Blueprint $table) {
$table->string('hashed_id')->unique()->after('id');
});
use Veelasky\HashId\HashIdTrait;
class User extends Model {
use HashIdTrait;
protected $hashId = 'hashed_id'; // Custom column name
}
Route::get('/users/{hashed_id}', [UserController::class, 'show']);
User::chunk(1000, function ($users) {
foreach ($users as $user) {
$user->hashed_id = $user->getHashId();
$user->save();
}
});
belongsTo, hasMany, etc., but ensure foreign keys reference original IDs.whereHas('posts', fn($q) => $q->whereHashedId($hash))).creating or saving events.HashId::encode()/decode() in feature tests to mock hashes.hashed_id columns in a low-traffic window.getHashId() or setHashId() for model-specific rules.HashId::decode($hash) helper to logs for validation.tinker to test hash generation:
$user = new User; $user->id = 123; echo $user->hashed_id;
How can I help you explore Laravel packages today?