1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-13 22:54:25 +01:00
invoiceninja/app/Console/Commands/SubdomainFill.php

96 lines
2.0 KiB
PHP
Raw Normal View History

2021-06-22 09:24:14 +02:00
<?php
namespace App\Console\Commands;
use App\Libraries\MultiDB;
use App\Models\Company;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Storage;
class SubdomainFill extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'ninja:subdomain';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Pad subdomains';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
$c1 = Company::on('db-ninja-01')->whereNull('subdomain')->orWhere('subdomain', '')->get();
$c2 = Company::on('db-ninja-02')->whereNull('subdomain')->orWhere('subdomain', '')->get();
$c1->each(function ($company){
$company->subdomain = MultiDB::randomSubdomainGenerator();
$company->save();
});
$c2->each(function ($company){
$company->subdomain = MultiDB::randomSubdomainGenerator();
$company->save();
});
2021-06-22 09:45:55 +02:00
2021-06-25 11:56:36 +02:00
// $db1 = Company::on('db-ninja-01')->get();
2021-06-22 09:45:55 +02:00
2021-06-25 11:56:36 +02:00
// $db1->each(function ($company){
2021-06-22 09:45:55 +02:00
2021-06-25 11:56:36 +02:00
// $db2 = Company::on('db-ninja-02a')->find($company->id);
2021-06-22 09:45:55 +02:00
2021-06-25 11:56:36 +02:00
// if($db2)
// {
// $db2->subdomain = $company->subdomain;
// $db2->save();
// }
2021-06-22 09:45:55 +02:00
2021-06-25 11:56:36 +02:00
// });
2021-06-22 09:45:55 +02:00
2021-06-25 11:56:36 +02:00
// $db1 = null;
// $db2 = null;
2021-06-22 09:45:55 +02:00
2021-06-25 11:56:36 +02:00
// $db2 = Company::on('db-ninja-02')->get();
2021-06-22 09:45:55 +02:00
2021-06-25 11:56:36 +02:00
// $db2->each(function ($company){
2021-06-22 09:45:55 +02:00
2021-06-25 11:56:36 +02:00
// $db1 = Company::on('db-ninja-01a')->find($company->id);
2021-06-22 09:45:55 +02:00
2021-06-25 11:56:36 +02:00
// if($db1)
// {
// $db1->subdomain = $company->subdomain;
// $db1->save();
// }
// });
2021-06-22 09:24:14 +02:00
}
}