Open dtemoment2015 opened 1 year ago
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:
<?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");
}
}
php artisan generate:tenant-models --tenants=tenant_id_you_have
@hanny-ph
I think you can just do
php artisan tenants:run code:models
IDE Helper Related: 1141
Tenancy For Laravel Docs: Tenant Commands
Plz tell me how to connect with stancl/tenancy