2018-07-13 04:53:44 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
|
2021-06-29 03:18:52 +00:00
|
|
|
use App\Models\{Account,User};
|
2018-07-13 04:53:44 +00:00
|
|
|
|
|
|
|
class UserAccountMerge extends Command
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The name and signature of the console command.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $signature = 'user:merge';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The console command description.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
2019-06-07 06:54:27 +00:00
|
|
|
protected $description = 'This utility will create a User account from the Account entries';
|
2018-07-13 04:53:44 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new command instance.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute the console command.
|
|
|
|
*
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function handle()
|
|
|
|
{
|
|
|
|
foreach (Account::all() as $ao)
|
|
|
|
{
|
|
|
|
if (is_null($ao->user_id) AND $ao->email)
|
|
|
|
{
|
|
|
|
$o = User::where('email',$ao->email)->first();
|
|
|
|
|
|
|
|
if (! $o) {
|
|
|
|
$o = new User;
|
|
|
|
$o->id = $ao->id;
|
|
|
|
$o->site_id = $ao->site_id;
|
|
|
|
$o->email = $ao->email;
|
|
|
|
$o->password = $ao->password;
|
|
|
|
$o->active = $ao->active;
|
|
|
|
$o->title = $ao->title;
|
|
|
|
$o->firstname = $ao->first_name;
|
|
|
|
$o->lastname = $ao->last_name;
|
|
|
|
$o->country_id = $ao->country_id;
|
|
|
|
$o->address1 = $ao->address1;
|
|
|
|
$o->address2 = $ao->address2;
|
|
|
|
$o->city = $ao->city;
|
|
|
|
$o->state = $ao->state;
|
|
|
|
$o->postcode = $ao->zip;
|
|
|
|
$o->save();
|
|
|
|
}
|
|
|
|
|
|
|
|
$ao->user_id = $o->id;
|
|
|
|
$ao->save();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|