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

Can not create hostname #403

Closed RushabhJoshi closed 6 years ago

RushabhJoshi commented 6 years ago

Earlier everything works perfectly but suddenly I am not able to create new tenant I also followed the documentation of Full-featured app

My sample code is

$website = new \Hyn\Tenancy\Models\Website;
app(\Hyn\Tenancy\Repositories\WebsiteRepository::class)->create($website);

$hostname = new \Hyn\Tenancy\Models\Hostname;
$hostname->fqdn = 'tenatname.localhost';
app(\Hyn\Tenancy\Repositories\HostnameRepository::class)->attach($hostname, $website);

..



tenancy.php config

<?php

/*
 * This file is part of the hyn/multi-tenant package.
 *
 * (c) Daniël Klabbers <daniel@klabbers.email>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @see https://laravel-tenancy.com
 * @see https://github.com/hyn/multi-tenant
 */

use Hyn\Tenancy\Database\Connection;

return [
    'models' => [
        /**
         * Specify different models to be used for the global, system database
         * connection. These are also used in their relationships. Models
         * used have to implement their respective contracts and
         * either extend the SystemModel or use the trait
         * UsesSystemConnection.
         */

        // Must implement \Hyn\Tenancy\Contracts\Customer
        'customer' => \Hyn\Tenancy\Models\Customer::class,

        // Must implement \Hyn\Tenancy\Contracts\Hostname
        'hostname' => \Hyn\Tenancy\Models\Hostname::class,

        // Must implement \Hyn\Tenancy\Contracts\Website
        'website' => \Hyn\Tenancy\Models\Website::class
    ],
    'website' => [
        /**
         * Each website has a short random hash that identifies this entity
         * to the application. By default this id is randomized and fully
         * auto-generated. In case you want to force your own logic for
         * when you need to have a better overview of the complete
         * tenant folder structure, disable this and implement
         * your own id generation logic.
         */
        'disable-random-id' => false,

        /**
         * The random Id generator is responsible for creating the hash as mentioned
         * above. You can override what generator to use by modifying this value
         * in the configuration.
         *
         * @warn This won't work if disable-random-id is true.
         */
        'random-id-generator' => Hyn\Tenancy\Generators\Uuid\ShaGenerator::class,

        /**
         * Enable this flag in case you're using a driver that does not support
         * database username or database name with a length of more than 32 characters.
         *
         * This should be enabled for MySQL, but not for MariaDB and PostgreSQL.
         */
        'uuid-limit-length-to-32' => env('LIMIT_UUID_LENGTH_32', false),

        /**
         * Specify the disk you configured in the filesystems.php file where to store
         * the tenant specific files, including media, packages, routes and other
         * files for this particular website.
         *
         * @info If not set, will revert to the default filesystem.
         */
        'disk' => null,

        /**
         * Automatically generate a tenant directory based on the random id of the
         * website. Uses the above disk to store files to override system-wide
         * files.
         *
         * @info set to false to disable.
         */
        'auto-create-tenant-directory' => true,

        /**
         * Automatically rename the tenant directory when the random id of the
         * website changes. This should not be too common, but in case it happens
         * we automatically want to move files accordingly.
         *
         * @info set to false to disable.
         */
        'auto-rename-tenant-directory' => true,

        /**
         * Automatically deletes the tenant specific directory and all files
         * contained within.
         *
         * @see
         * @info set to true to enable.
         */
        'auto-delete-tenant-directory' => env('AUTO_DELETE_TENANT_DIRECTORY', false),

        /**
         * Time to cache websites in minutes. Set to false to disable.
         */
        'cache' => 10,
    ],
    'hostname' => [
        /**
         * If you want the multi tenant application to fall back to a default
         * hostname/website in case the requested hostname was not found
         * in the database, complete in detail the default hostname.
         *
         * @warn this must be a FQDN, these have no protocol or path!
         */
        'default' => env('TENANCY_DEFAULT_HOSTNAME'),
        /**
         * The package is able to identify the requested hostname by itself,
         * disable to get full control (and responsibility) over hostname
         * identification. The hostname identification is needed to
         * set a specific website as currently active.
         *
         * @see src/Jobs/HostnameIdentification.php
         */
        'auto-identification' => env('TENANCY_AUTO_HOSTNAME_IDENTIFICATION', true),

        /**
         * In case you want to have the tenancy environment set up early,
         * enable this flag. This will run the tenant identification
         * inside a middleware. This will eager load tenancy.
         *
         * A good use case is when you have set "tenant" as the default
         * database connection.
         */
        'early-identification' => env('TENANCY_EARLY_IDENTIFICATION', false),

        /**
         * Abort application execution in case no hostname was identified. This will throw a
         * 404 not found in case the tenant hostname was not resolved.
         *
         * @see https://hyn.readme.io/v3.0/docs/tenancy#section-hostnameabort-without-identified-hostname
         */
        'abort-without-identified-hostname' => true,

        /**
         * Time to cache hostnames in minutes. Set to false to disable.
         */
        'cache' => 10,
    ],
    'db' => [
        /**
         * The default connection to use; this overrules the Laravel database.default
         * configuration setting. In Laravel this is normally configured to 'mysql'.
         * You can set a environment variable to override the default database
         * connection to - for instance - the tenant connection 'tenant'.
         *
         * @see https://hyn.readme.io/v3.0/docs/tenancy#section-dbdefault
         */
        'default' => env('TENANCY_DEFAULT_CONNECTION'),
        /**
         * Used to give names to the system and tenant database connections. By
         * default we configure 'system' and 'tenant'. The tenant connection
         * is set up automatically by this package.
         *
         * @see src/Database/Connection.php
         * @var system-connection-name The database connection name to use for the global/system database.
         * @var tenant-connection-name The database connection name to use for the tenant database.
         */
        'system-connection-name' => env('TENANCY_SYSTEM_CONNECTION_NAME', Connection::DEFAULT_SYSTEM_NAME),
        'tenant-connection-name' => env('TENANCY_TENANT_CONNECTION_NAME', Connection::DEFAULT_TENANT_NAME),

        /**
         * The tenant division mode specifies to what database websites will be
         * connecting. The default setup is to use a new database per tenant.
         * In case you prefer to use the same database with a table prefix,
         * set the mode to 'prefix'.
         *
         * @see src/Database/Connection.php
         */
        'tenant-division-mode' => env('TENANCY_DATABASE_DIVISION_MODE', 'database'),

        /**
         * The database password generator takes care of creating a valid hashed
         * string used for tenants to connect to the specific database. Do
         * note that this will only work in 'division modes' that set up
         * a connection to a separate database.
         */
        'password-generator' => Hyn\Tenancy\Generators\Database\DefaultPasswordGenerator::class,

        /**
         * The tenant migrations to be run during creation of a tenant. Specify a directory
         * to run the migrations from. If specified these migrations will be executed
         * whenever a new tenant is created.
         *
         * @info set to false to disable auto migrating.
         *
         * @warn this has to be an absolute path, feel free to use helper methods like
         * base_path() or database_path() to set this up.
         */
        'tenant-migrations-path' => database_path('migrations/tenant'),

        /**
         * Seeds the newly created tenant database based on this Seeder.
         *
         * @info requires tenant-migrations-path to be in use.
         *
         * @warn specify a valid fully qualified class name.
         * @example App\Seeders\AdminSeeder::class
         */
        'tenant-seed-class' => TenantDatabaseSeeder::class,

        /**
         * Automatically generate a tenant database based on the random id of the
         * website.
         *
         * @info set to false to disable.
         */
        'auto-create-tenant-database' => true,

        /**
         * Automatically rename the tenant database when the random id of the
         * website changes. This should not be too common, but in case it happens
         * we automatically want to move databases accordingly.
         *
         * @info set to false to disable.
         */
        'auto-rename-tenant-database' => true,

        /**
         * Automatically deletes the tenant specific database and all data
         * contained within.
         *
         * @info set to true to enable.
         */
        'auto-delete-tenant-database' => env('AUTO_DELETE_TENANT_DATABASE', false),
    ],
    'folders' => [
        'config' => [
            /**
             * Merge configuration files from the config directory
             * inside the tenant directory with the global configuration files.
             */
            'enabled' => true,

            /**
             * List of configuration files to ignore, preventing override of crucial
             * application configurations.
             */
            'blacklist' => ['database', 'tenancy', 'webserver'],
        ],
        'routes' => [
            /**
             * Allows adding and overriding URL routes inside the tenant directory.
             */
            'enabled' => true,

            /**
             * Prefix all tenant routes.
             */
            'prefix' => null,
        ],
        'trans' => [
            /**
             * Allows reading translation files from a trans directory inside
             * the tenant directory.
             */
            'enabled' => true,

            /**
             * Will override the global translations with the tenant translations.
             * This is done by overriding the laravel default translator with the new path.
             */
            'override-global' => true,

            /**
             * In case you disabled global override, specify a namespace here to load the
             * tenant translation files with.
             */
            'namespace' => 'tenant',
        ],
        'vendor' => [
            /**
             * Allows using a custom vendor (composer driven) folder inside
             * the tenant directory.
             */
            'enabled' => true,
        ],
        'media' => [
            /**
             * Mounts the assets directory with (static) files for public use.
             */
            'enabled' => true,
        ]
    ]
];

webserver.php config

<?php

/*
 * This file is part of the hyn/multi-tenant package.
 *
 * (c) Daniël Klabbers <daniel@klabbers.email>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @see https://laravel-tenancy.com
 * @see https://github.com/hyn/multi-tenant
 */

return [

    /**
     * Let's Encrypt free SSL certificates for automatic https links of your tenant websites.
     *
     * @see http://www.letsencrypt.org
     */
    'lets-encrypt' => [
        /**
         * Whether Let's Encrypt is actively used to manage the SSL certificates of this domain.
         *
         * @info The Let's Encrypt is a non-terminal, pure PHP implementation.
         */
        'enabled' => true,
    ],

    /**
     * Apache2 is one of the most widely adopted webserver packages available.
     *
     * @see http://httpd.apache.org/docs/
     * @see https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-ubuntu
     */
    'apache2' => [
        /**
         * Whether the integration with Apache2 is currently active.
         *
         * @see
         */
        'enabled' => false,

        /**
         * Define the ports of your Apache service.
         */
        'ports' => [
            /**
             * HTTP, non-SSL port.
             *
             * @default 80
             */
            'http' => 80,
            /**
             * HTTPS, SSL port.
             *
             * @default 443
             */
            'https' => 443
        ],

        /**
         * The generator taking care of hooking into the Apache services and files.
         */
        'generator' => \Hyn\Tenancy\Generators\Webserver\Vhost\ApacheGenerator::class,

        /**
         * Specify the disk you configured in the filesystems.php file where to store
         * the tenant vhost configuration files.
         *
         * @see
         * @info If not set, will revert to the default filesystem.
         */
        'disk' => null,

        'paths' => [

            /**
             * Location where vhost configuration files can be found.
             *
             * @see https://hyn.readme.io/v3.0/docs/webserverphp#section-apachepathsvhost-files
             */
            'vhost-files' => [
                '/etc/apache2/sites-enabled/'
            ],

            'actions' => [
                'exists' => '/etc/init.d/apache2',
                'test-config' => 'apache2ctl -t',
                'reload' => 'apache2ctl graceful'
            ]
        ]
    ]
];

Error log

 SQLSTATE[42S02]: Base table or view not found: 1146 Table 'd69c511cbc3a41acb6b8a910ee685081.hostnames' doesn't exist (SQL: insert into `hostnames  
  ` (`fqdn`, `website_id`, `updated_at`, `created_at`) values (tenatname.localhost, 2, 2018-03-25 07:53:07, 2018-03-25 07:53:07))     
Thijmen commented 6 years ago

Which trait does your Hostname model use?

fletch3555 commented 6 years ago

@Thijmen, the snippet above shows he's using the one from this package.

Thijmen commented 6 years ago

How does your database.php-config looks like?

RushabhJoshi commented 6 years ago
<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Default Database Connection Name
    |--------------------------------------------------------------------------
    |
    | Here you may specify which of the database connections below you wish
    | to use as your default connection for all database work. Of course
    | you may use many connections at once using the Database library.
    |
    */

    'default' => env('DB_CONNECTION', 'sqlite'),

    /*
    |--------------------------------------------------------------------------
    | Database Connections
    |--------------------------------------------------------------------------
    |
    | Here are each of the database connections setup for your application.
    | Of course, examples of configuring each database platform that is
    | supported by Laravel is shown below to make development simple.
    |
    |
    | All database work in Laravel is done through the PHP PDO facilities
    | so make sure you have the driver for your particular database of
    | choice installed on your machine before you begin development.
    |
    */

    'connections' => [

        'sqlite' => [
            'driver' => 'sqlite',
            'database' => env('DB_DATABASE', database_path('local.sqlite')), __DIR__.'/../database/local.sqlite',// 
            'prefix' => '',
        ],

        'system' => [
            'host' => env('DB_HOST', '127.0.0.1'),
            'driver' =>  env('DB_DRIVER', 'mysql') ,
            'username' => env('DB_USERNAME', 'tenancy'),
            'database' => env('DB_DATABASE', 'tenancy'),
            'password' => env('DB_PASSWORD'),
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'strict' => true,
            'engine' => null,
        ],
/*
        'mysql' => [
            'driver' => 'mariadb',
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '3306'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'unix_socket' => env('DB_SOCKET', ''),
            'charset' => 'utf8mb4',
            'collation' => 'utf8mb4_unicode_ci',
            'prefix' => '',
            'strict' => true,
            'engine' => null,
        ],
*/
        'pgsql' => [
            'driver' => 'pgsql',
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '5432'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'charset' => 'utf8',
            'prefix' => '',
            'schema' => 'public',
            'sslmode' => 'prefer',
        ],

        'sqlsrv' => [
            'driver' => 'sqlsrv',
            'host' => env('DB_HOST', 'localhost'),
            'port' => env('DB_PORT', '1433'),
            'database' => env('DB_DATABASE', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'charset' => 'utf8',
            'prefix' => '',
        ],

    ],

    /*
    |--------------------------------------------------------------------------
    | Migration Repository Table
    |--------------------------------------------------------------------------
    |
    | This table keeps track of all the migrations that have already run for
    | your application. Using this information, we can determine which of
    | the migrations on disk haven't actually been run in the database.
    |
    */

    'migrations' => 'migrations',

    /*
    |--------------------------------------------------------------------------
    | Redis Databases
    |--------------------------------------------------------------------------
    |
    | Redis is an open source, fast, and advanced key-value store that also
    | provides a richer set of commands than a typical key-value systems
    | such as APC or Memcached. Laravel makes it easy to dig right in.
    |
    */

    'redis' => [

        'client' => 'predis',

        'default' => [
            'host' => env('REDIS_HOST', '127.0.0.1'),
            'password' => env('REDIS_PASSWORD', null),
            'port' => env('REDIS_PORT', 6379),
            'database' => 0,
        ],

    ],

];
luceos commented 6 years ago

Does your system database have a hostnames table? Aka did you run those migrations?

RushabhJoshi commented 6 years ago

Yes, as I said it was working before, FYI I run this code in a console command

luceos commented 6 years ago

What value has DB_CONNECTION in your .env?

RushabhJoshi commented 6 years ago
DB_CONNECTION=system
DB_USERNAME=tenancy
DB_PASSWORD=tenancy
DB_DATABASE=tenancy
DB_DRIVER=mysql

here code successfully created a website, the problem only occurs when we try to create hostname which is next to creating a website

luceos commented 6 years ago

This is truly odd. It seems it's trying to save hostnames to the tenant connection instead of the system connection. Is this a clean install or did you modify any logic so far? You said it worked earlier and now it doesn't, any pointers what changed in between?

RushabhJoshi commented 6 years ago

I haven't changed any code. In between, I just added other packages.

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": ">=7.0.0",
        "ajthinking/tinx": "^2.0",
        "caouecs/laravel-lang": "~3.0",
        "cartalyst/stripe-laravel": "7.0.*",
        "dannyvankooten/laravel-vat": "dev-master",
        "doctrine/dbal": "^2.6",
        "fideloper/proxy": "~3.3",
        "florianv/laravel-swap": "^1.1",
        "hyn/multi-tenant": "5.*",
        "ijeffro/laravel-airlines": "dev-master",
        "ijeffro/laravel-airports": "dev-master",
        "jeroennoten/laravel-adminlte": "^1.22",
        "laravel/cashier": "~7.0",
        "laravel/framework": "5.5.*",
        "laravel/tinker": "~1.0",
        "laravelcollective/html": "^5.5.0",
        "laravelnews/laravel-twbs4": "^1.3",
        "mcamara/laravel-localization": "^1.3",
        "php-http/guzzle6-adapter": "^1.1",
        "php-http/message": "^1.6",
        "propaganistas/laravel-intl": "^1.2",
        "spatie/laravel-permission": "^2.7",
        "ybr-nx/laravel-mariadb": "^1.0"
    },
    "require-dev": {
        "codedungeon/phpunit-result-printer": "^0.7.0",
        "filp/whoops": "~2.0",
        "fzaninotto/faker": "~1.4",
        "mockery/mockery": "0.9.*",
        "phpunit/phpunit": "~6.0"
    },
    "autoload": {
        "classmap": [
            "database/seeds",
            "database/factories"
        ],
        "psr-4": {
            "App\\": "app/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        }
    },
    "extra": {
        "laravel": {
            "dont-discover": [
            ],
            "providers":[
                "Propaganistas\\LaravelIntl\\IntlServiceProvider::class"
            ]

        }
    },
    "scripts": {
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate"
        ],
        "post-autoload-dump": [
            "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover"
        ]
    },
    "config": {
        "preferred-install": "dist",
        "sort-packages": true,
        "optimize-autoloader": true
    }
}

composer.json

RushabhJoshi commented 6 years ago

Hello @luceos, I have gone through the git commit one by one and appeared that nothing really changed which affect the code

I thought it is because of this package laravelcollectiv/html

So I have removed this package and its provider from app.php config file still got no luck

Other changes are related to controller, routes, migrations, and model (the models are user-defined I haven't changed any package model or override them).

here is my stack trace

Exception trace:
 PDO->prepare() at /home/rushabh/localhost/p-saas/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:77
 Doctrine\DBAL\Driver\PDOConnection->prepare() at /home/rushabh/localhost/p-saas/vendor/laravel/framework/src/Illuminate/Database/Connection.php:452
 Illuminate\Database\Connection->Illuminate\Database\{closure}() at /home/rushabh/localhost/p-saas/vendor/laravel/framework/src/Illuminate/Database/Connection.php:657
 Illuminate\Database\Connection->runQueryCallback() at /home/rushabh/localhost/p-saas/vendor/laravel/framework/src/Illuminate/Database/Connection.php:624
 Illuminate\Database\Connection->run() at /home/rushabh/localhost/p-saas/vendor/laravel/framework/src/Illuminate/Database/Connection.php:459
 Illuminate\Database\Connection->statement() at /home/rushabh/localhost/p-saas/vendor/laravel/framework/src/Illuminate/Database/Connection.php:411
 Illuminate\Database\Connection->insert() at /home/rushabh/localhost/p-saas/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/Processor.php:32
 Illuminate\Database\Query\Processors\Processor->processInsertGetId() at /home/rushabh/localhost/p-saas/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2137
 Illuminate\Database\Query\Builder->insertGetId() at /home/rushabh/localhost/p-saas/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:1281
 Illuminate\Database\Eloquent\Builder->__call() at /home/rushabh/localhost/p-saas/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:722
 Illuminate\Database\Eloquent\Model->insertAndSetId() at /home/rushabh/localhost/p-saas/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:687
 Illuminate\Database\Eloquent\Model->performInsert() at /home/rushabh/localhost/p-saas/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:550
 Illuminate\Database\Eloquent\Model->save() at /home/rushabh/localhost/p-saas/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/HasOneOrMany.php:250
 Illuminate\Database\Eloquent\Relations\HasOneOrMany->save() at /home/rushabh/localhost/p-saas/vendor/hyn/multi-tenant/src/Repositories/HostnameRepository.php:176
 Hyn\Tenancy\Repositories\HostnameRepository->attach() at /home/rushabh/localhost/p-saas/app/Console/Commands/Utils.php:73
 App\Console\Commands\Utils->handle() at n/a:n/a
 call_user_func_array() at /home/rushabh/localhost/p-saas/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:29
 Illuminate\Container\BoundMethod::Illuminate\Container\{closure}() at /home/rushabh/localhost/p-saas/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:87
 Illuminate\Container\BoundMethod::callBoundMethod() at /home/rushabh/localhost/p-saas/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php:31
 Illuminate\Container\BoundMethod::call() at /home/rushabh/localhost/p-saas/vendor/laravel/framework/src/Illuminate/Container/Container.php:549
 Illuminate\Container\Container->call() at /home/rushabh/localhost/p-saas/vendor/laravel/framework/src/Illuminate/Console/Command.php:183
 Illuminate\Console\Command->execute() at /home/rushabh/localhost/p-saas/vendor/symfony/console/Command/Command.php:252
 Symfony\Component\Console\Command\Command->run() at /home/rushabh/localhost/p-saas/vendor/laravel/framework/src/Illuminate/Console/Command.php:170
 Illuminate\Console\Command->run() at /home/rushabh/localhost/p-saas/vendor/symfony/console/Application.php:938
 Symfony\Component\Console\Application->doRunCommand() at /home/rushabh/localhost/p-saas/vendor/symfony/console/Application.php:240
 Symfony\Component\Console\Application->doRun() at /home/rushabh/localhost/p-saas/vendor/symfony/console/Application.php:148
 Symfony\Component\Console\Application->run() at /home/rushabh/localhost/p-saas/vendor/laravel/framework/src/Illuminate/Console/Application.php:88
 Illuminate\Console\Application->run() at /home/rushabh/localhost/p-saas/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:121
 Illuminate\Foundation\Console\Kernel->handle() at /home/rushabh/localhost/p-saas/artisan:37
luceos commented 6 years ago

What is the environment like, is this virtualised?

RushabhJoshi commented 6 years ago

@luceos I am running on my laptop os, No virtual setup Ubuntu 16.04

luceos commented 6 years ago

I have no clue what is wrong. But it's obvious the wrong connection is being used.

If possible you might want to upgrade to Laravel 5.6 and Hyn 5.1.*; perhaps that will resolve this issue. Otherwise you'd have to debug this as I can't seem to reproduce.

RushabhJoshi commented 6 years ago

Sure, Thanks a lot

luceos commented 6 years ago

Feel free to re-open when you have more information or, if possible, provide a way for me to reproduce.

RushabhJoshi commented 6 years ago

Hello @luceos ,

I have updated the laravel version and package still having the same error

luceos commented 6 years ago

Okay so this might be related to an insert on a has many relationships when attaching the hostname to the website. The relationship might default back on the wrong connection.

I'll look into it.

luceos commented 6 years ago

@RushabhJoshi have you been able to move forward? I was just reading into this and still think it's very curious that such simple code misbehaves this badly. The first snippet you posted in this issue, where did you place that (controller, repository)?

RushabhJoshi commented 6 years ago

Hey, Sorry for late reply @luceos It is strange now I can not reproduce the same error I have tried after some time and the same code is not producing an error pretty strange for me also. I think I don't have this issue now. I am closing this issue now. You help is much appreciated

Thank you