Skip to content

Commit

Permalink
add alter console command
Browse files Browse the repository at this point in the history
  • Loading branch information
martiendt committed Apr 27, 2020
1 parent 6f9cc0f commit ba19126
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions app/Console/Commands/AlterConsole.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php

namespace App\Console\Commands;

use App\Model\HumanResource\Employee\Employee;
use App\Model\Project\Project;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;

class AlterConsole extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'dev:alter-console';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Temporary';

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$projects = Project::where('is_generated', true)->get();
foreach ($projects as $project) {
config()->set('database.connections.tenant.database', env('DB_DATABASE').'_'.strtolower($project->code));
DB::connection('tenant')->reconnect();
$count = Employee::all()->count();
if ($count > 0) {
$this->line('PROJECT: '.$project->code .' = '. $project->count());
}
}
}
}

0 comments on commit ba19126

Please sign in to comment.