GithubHelp home page GithubHelp logo

stancl/tenancy how use about laravel HOT 2 OPEN

dtemoment2015 avatar dtemoment2015 commented on May 28, 2024
stancl/tenancy how use

from laravel.

Comments (2)

hanny-ph avatar hanny-ph commented on May 28, 2024

I think it's a bit difficult to seamlessly integrate with stancl/tenancy unless the author adds some changes, I could be wrong though.

I'd like to give you an idea of how to solve the issue, I'm sorry it's really ugly, but we can do nothing here. Please do the following steps:

  1. Create a new command.
  2. Copy the below code to your command class.
<?php

namespace App\Console\Commands;

use Illuminate\Contracts\Container\BindingResolutionException;
use Illuminate\Filesystem\Filesystem;
use Reliese\Coders\Model\Config;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Reliese\Coders\Model\Factory as ModelFactory;
use Reliese\Support\Classify;
use Stancl\Tenancy\Concerns\HasATenantsOption;
use Stancl\Tenancy\Concerns\TenantAwareCommand;

class GenerateTenantModels extends Command
{
    use TenantAwareCommand, HasATenantsOption;

    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'generate:tenant-models';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Generate Tenant Models';

    /**
     * Execute the console command.
     * @throws BindingResolutionException
     */
    public function handle()
    {
        $models = new ModelFactory(
            app()->make('db'),
            app()->make(Filesystem::class),
            new Classify(),
            new Config(app()->make('config')->get('models'))
        );
        $connection = DB::connection();

        $models->on($connection->getName())->map('public');
        $this->info("Check out your models for public");
    }
}
  1. Run php artisan generate:tenant-models --tenants=tenant_id_you_have

from laravel.

Fludem avatar Fludem commented on May 28, 2024

@hanny-ph

I think you can just do

php artisan tenants:run code:models

IDE Helper Related: 1141

Tenancy For Laravel Docs: Tenant Commands

from laravel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.