New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

laravie/dhosa

Hot Swapping for Laravel Eloquent
63,303 4

Larablocks Analysis

laravie/dhosa works with Laravel 6, 7 and 8 (latest release v1.1.0, Aug 31, 2020), all past end of life (the last on Jan 24, 2023): no more fixes, even for security.

Recommendation checks

Not advised

Not advised: no release or commit in over 2 years.

  • No release or commit in over 2 years
  • Supports only Laravel 6, 7 and 8, past end of life since Jan 24, 2023
  • No release in the last 12 months (last: Aug 31, 2020)
  • 936 downloads a month (needs 10,000)
  • 4 GitHub stars (needs 100)

State

Likely abandoned
  • No release or commit in over 2 years.
  • Last stable release: Aug 31, 2020.
  • No releases in the last 12 months.
  • First released: Mar 4, 2020.
  • Monthly downloads: 936.
  • 1 open issue on GitHub.

Data from Packagist and GitHub, checked by Larablocks on Nov 27, 2026.

Install
composer require laravie/dhosa
Latest Version:v1.1.0
PHP:>=7.3
Laravel:6 · 7 · 8
License:MIT
Last Updated:Mar 13, 2022
Links: GitHub  ·  Packagist
Maintainer: crynobone

Hot Swapping for Laravel Eloquent

Build Status Latest Stable Version Total Downloads Latest Unstable Version License

Dhosa allows developers to implement hot-swapping capabilities on Eloquent models. This will helps package developer to create a base model and app developer can extends upon the base model while making sure that all the relationship uses the proper model.

Installation

To install through composer, run the following command from terminal:

composer require "laravie/dhosa"

Usages

Enable Hot-Swap

To enable hot-swap to any Eloquent all you need to do is use Laravie\Dhosa\Concerns\Swappable and implements the method.

<?php

namespace App\Models;

// ...
use Illuminate\Foundation\Auth\User as Authenticatable;
use Laravie\Dhosa\Concerns\Swappable;

class User extends Authenticatable
{
    use Swappable;
    
    /**
     * Get Hot-swappable alias name.
     *
     * @return string
     */
    public static function hsAliasName(): string
    {
        return 'User';
    }
}

Registering Hot-Swap

use Laravie\Dhosa\HotSwap;

HotSwap::register('Orchestra\Model\User');

Overriding Hot-Swap

In the App\Providers\AppServiceProvider we can now override the resolution of User to App\User by adding:

use Laravie\Dhosa\HotSwap;

HotSwap::override('User', 'App\User');

Defining relationship

You can define relationship by using the following code:

use Orchestra\Model\User;

/* ... */

public function user() 
{
    return $this->belongsTo(User::hsFinder());
}

Making queries

use Orchestra\Model\User;

$user = User::hs(); // return instance of App\User

$user = User::hs()->query(); // return a query builder for App\User

$user = User::hsOn('api'); // return a query builder for App\User using `api` db connection.

$user = User::hsOnWriteConnection(); // return a query builder for App\User using write PDO connection.

Helpers methods

use Orchestra\Model\Role;
use Orchestra\Model\User;

User::hsAliasName(); // return "User"

User::hsFinder(); // return "App\User"

Role::hsFinder(); // return "Orchestra\Model\Role"

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

670,032,257 9,703
laravel/framework

The Laravel Framework.

640,572,096 35,338
laravel/tinker

Powerful REPL for the Laravel framework.

546,909,908 7,440
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

465,816,364 607
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

431,187,642 4,660

Version History

Version Released PHP Laravel License
v1.1.0 >=7.3 ^6.0 || ^7.0 || ^8.0 MIT
v1.0.0 >=7.2 ^6.0 || ^7.0 MIT