-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1208 from younginnovations/1185-dashboard-visuali…
…zation-api Resolved: 1185-dashboard-visualization-api
- Loading branch information
Showing
66 changed files
with
36,061 additions
and
1,922 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Console\Commands; | ||
|
||
use App\IATI\Models\Organization\Organization; | ||
use App\IATI\Models\User\User; | ||
use Arr; | ||
use DB; | ||
use Illuminate\Console\Command; | ||
|
||
/** | ||
* Class FillOrgRegistrationType. | ||
*/ | ||
class FillOrgRegistrationType extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'command:fillOrgRegistrationType'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Fill registration type in organization'; | ||
|
||
/** | ||
* Execute the console command. | ||
*/ | ||
public function handle(): void | ||
{ | ||
try { | ||
DB::beginTransaction(); | ||
|
||
$registrationMethodMapping = [ | ||
'new_org' =>'new_org', | ||
'existing_org' =>'existing_org', | ||
'user_create' =>'existing_org', | ||
]; | ||
|
||
$organizations = Organization::get(); | ||
|
||
foreach ($organizations as $organization) { | ||
$user = User::where('organization_id', $organization->id)->first(); | ||
$userRegistrationType = $user ? $user->registration_method : 'existing_org'; | ||
$organization['registration_type'] = Arr::get($registrationMethodMapping, $userRegistrationType, 'existing_org'); | ||
$organization->timestamps = false; | ||
$organization->saveQuietly(['touch' => false]); | ||
} | ||
|
||
DB::commit(); | ||
} catch (\Exception $e) { | ||
DB::rollback(); | ||
logger()->error($e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.