tenancy / multi-tenant

Run multiple websites using the same Laravel installation while keeping tenant specific data separated for fully independent multi-domain setups, previously github.com/hyn/multi-tenant
https://tenancy.dev
MIT License
2.56k stars 394 forks source link

How to update the nginx configuration file synchronously when deleting hostname #981

Closed szwss closed 3 years ago

szwss commented 3 years ago

Description

When creating the hostname, I call the following command. The nginx configuration file will be automatically updated and synchronized to all the hostnames under the website:

        $hostname = new \App\Models\SystemCentral\Hostname;
        $hostname->fqdn = $request->fqdn;
        $hostname->website_id = $website->id;

        $hostname = app(\Hyn\Tenancy\Contracts\Repositories\HostnameRepository::class)->create($hostname);
        app(\Hyn\Tenancy\Contracts\Repositories\HostnameRepository::class)->attach($hostname, $website);

But when I delete the hostname, the nginx configuration file will not be updated, I tried the following methods, and the nginx configuration file has no effect:

          $hostname = \App\Models\SystemCentral\Hostname::onlyTrashed()->find($hostname);
            app(\Hyn\Tenancy\Contracts\Repositories\HostnameRepository::class)->delete($hostname,true);

            app(\Hyn\Tenancy\Contracts\Repositories\HostnameRepository::class)->detach($hostname);
            app(\Hyn\Tenancy\Contracts\Repositories\HostnameRepository::class)->update($hostname);

How can I update the nginx configuration file synchronously when I delete it?