diff --git a/app/Console/Commands/UserAccountMerge.php b/app/Console/Commands/UserAccountMerge.php
deleted file mode 100644
index 69a5837..0000000
--- a/app/Console/Commands/UserAccountMerge.php
+++ /dev/null
@@ -1,72 +0,0 @@
-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();
- }
- }
- }
-}
\ No newline at end of file
diff --git a/app/Models/Account.php b/app/Models/Account.php
index d2917b5..5a964e0 100644
--- a/app/Models/Account.php
+++ b/app/Models/Account.php
@@ -26,8 +26,8 @@ class Account extends Model implements IDs
const RECORD_ID = 'account';
public $incrementing = FALSE;
- protected $table = 'ab_account';
- public $timestamps = FALSE;
+ const CREATED_AT = 'date_orig';
+ const UPDATED_AT = 'date_last';
protected $appends = [
'active_display',
@@ -97,30 +97,14 @@ class Account extends Model implements IDs
public function scopeSearch($query,string $term)
{
// Build our where clause
- // First Name, Last name
- if (preg_match('/\ /',$term)) {
- [$fn,$ln] = explode(' ',$term,2);
-
- $query->where(function($query1) use ($fn,$ln,$term) {
- $query1->where(function($query2) use ($fn,$ln) {
- return $query2
- ->where('first_name','like','%'.$fn.'%')
- ->where('last_name','like','%'.$ln.'%');
- })
- ->orWhere('company','like','%'.$term.'%');
- });
-
- } elseif (is_numeric($term)) {
+ if (is_numeric($term)) {
$query->where('id','like','%'.$term.'%');
- } elseif (preg_match('/\@/',$term)) {
- $query->where('email','like','%'.$term.'%');
-
} else {
- $query
- ->where('company','like','%'.$term.'%')
- ->orWhere('first_name','like','%'.$term.'%')
- ->orWhere('last_name','like','%'.$term.'%');
+ $query->where('company','like','%'.$term.'%')
+ ->orWhere('address1','like','%'.$term.'%')
+ ->orWhere('address2','like','%'.$term.'%')
+ ->orWhere('city','like','%'.$term.'%');
}
return $query;
diff --git a/database/factories/AccountFactory.php b/database/factories/AccountFactory.php
index 66f26e6..b240bef 100644
--- a/database/factories/AccountFactory.php
+++ b/database/factories/AccountFactory.php
@@ -37,23 +37,13 @@ class AccountFactory extends Factory
'country_id' => $co->id,
// 'rtm_id',
'currency_id' => $cyo->id,
- // 'username',
- // 'password',
'active' => TRUE,
- // 'first_name',
- // 'last_name',
- // 'title',
- // 'email',
// 'company',
// 'address1',
// 'address2',
// 'city',
// 'state',
// 'zip',
- // 'email_type',
- // 'invoice_delivery',
- // 'mail_type',
- // 'remember_token',
// 'user_id',
];
}
diff --git a/database/migrations/2021_07_07_164413_rework_account.php b/database/migrations/2021_07_07_164413_rework_account.php
new file mode 100644
index 0000000..4dd09ee
--- /dev/null
+++ b/database/migrations/2021_07_07_164413_rework_account.php
@@ -0,0 +1,33 @@
+dropUnique('uq_username');
+ $table->dropColumn(['username','password','first_name','last_name','title','email','email_type','invoice_delivery','mail_type','remember_token']);
+ });
+
+ DB::statement('ALTER TABLE ab_account RENAME TO accounts');
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ //abort(500,'cant go back');
+ }
+}
diff --git a/resources/views/theme/backend/adminlte/u/invoice/home.blade.php b/resources/views/theme/backend/adminlte/u/invoice/home.blade.php
index 5f4d7c8..73aa5ce 100644
--- a/resources/views/theme/backend/adminlte/u/invoice/home.blade.php
+++ b/resources/views/theme/backend/adminlte/u/invoice/home.blade.php
@@ -49,7 +49,7 @@
{{ $o->account->company }}
{!! join('
',$o->account->address) !!}
- Email: {{ $o->account->email }}
+ Email: {{ $o->account->user->email }}
@if ($o->account->phone)
Phone: {{ $o->account->phone }}
@endif