deplay phase 1
This commit is contained in:
parent
e3dc1afd8e
commit
5a7478907e
68 changed files with 2831 additions and 818 deletions
|
|
@ -157,11 +157,11 @@ class ContactController extends Controller
|
|||
}
|
||||
|
||||
DB::transaction(function () use ($masterId, $dupeId) {
|
||||
DB::table('inquiries')->where('customer_id', $dupeId)->update(['customer_id' => $masterId]);
|
||||
DB::table('lead')->where('customer_id', $dupeId)->update(['customer_id' => $masterId]);
|
||||
DB::table('booking')->where('customer_id', $dupeId)->update(['customer_id' => $masterId]);
|
||||
DB::table('customer_mails')->where('customer_id', $dupeId)->update(['customer_id' => $masterId]);
|
||||
DB::table('lead_mails')->where('customer_id', $dupeId)->update(['customer_id' => $masterId]);
|
||||
DB::table('contacts')->where('id', $dupeId)->update([
|
||||
DB::table('customer')->where('id', $dupeId)->update([
|
||||
'merged_into_id' => $masterId,
|
||||
'merged_at' => now(),
|
||||
]);
|
||||
|
|
@ -175,16 +175,16 @@ class ContactController extends Controller
|
|||
private function countDuplicateGroups(string $type): int
|
||||
{
|
||||
return match ($type) {
|
||||
'email' => DB::table('contacts')->selectRaw('COUNT(*) as cnt')->whereNotNull('email')->where('email', '!=', '')->whereNull('merged_into_id')->whereNull('deleted_at')->groupBy('email')->havingRaw('COUNT(*) > 1')->get()->count(),
|
||||
'name_birthdate' => DB::table('contacts')->selectRaw('COUNT(*) as cnt')->whereNotNull('name')->whereNotNull('firstname')->whereNotNull('birthdate')->whereNull('merged_into_id')->whereNull('deleted_at')->groupBy('name', 'firstname', 'birthdate')->havingRaw('COUNT(*) > 1')->get()->count(),
|
||||
'name_zip' => DB::table('contacts')->selectRaw('COUNT(*) as cnt')->whereNotNull('name')->whereNotNull('firstname')->whereNotNull('zip')->where('zip', '!=', '')->whereNull('merged_into_id')->whereNull('deleted_at')->groupBy('name', 'firstname', 'zip')->havingRaw('COUNT(*) > 1')->get()->count(),
|
||||
'email' => DB::table('customer')->selectRaw('COUNT(*) as cnt')->whereNotNull('email')->where('email', '!=', '')->whereNull('merged_into_id')->whereNull('deleted_at')->groupBy('email')->havingRaw('COUNT(*) > 1')->get()->count(),
|
||||
'name_birthdate' => DB::table('customer')->selectRaw('COUNT(*) as cnt')->whereNotNull('name')->whereNotNull('firstname')->whereNotNull('birthdate')->whereNull('merged_into_id')->whereNull('deleted_at')->groupBy('name', 'firstname', 'birthdate')->havingRaw('COUNT(*) > 1')->get()->count(),
|
||||
'name_zip' => DB::table('customer')->selectRaw('COUNT(*) as cnt')->whereNotNull('name')->whereNotNull('firstname')->whereNotNull('zip')->where('zip', '!=', '')->whereNull('merged_into_id')->whereNull('deleted_at')->groupBy('name', 'firstname', 'zip')->havingRaw('COUNT(*) > 1')->get()->count(),
|
||||
default => 0,
|
||||
};
|
||||
}
|
||||
|
||||
private function findByEmail(): array
|
||||
{
|
||||
return DB::table('contacts')
|
||||
return DB::table('customer')
|
||||
->selectRaw('GROUP_CONCAT(id ORDER BY updated_at DESC, id DESC) as ids')
|
||||
->whereNotNull('email')->where('email', '!=', '')
|
||||
->whereNull('merged_into_id')->whereNull('deleted_at')
|
||||
|
|
@ -194,7 +194,7 @@ class ContactController extends Controller
|
|||
|
||||
private function findByNameBirthdate(): array
|
||||
{
|
||||
return DB::table('contacts')
|
||||
return DB::table('customer')
|
||||
->selectRaw('GROUP_CONCAT(id ORDER BY updated_at DESC, id DESC) as ids')
|
||||
->whereNotNull('name')->whereNotNull('firstname')->whereNotNull('birthdate')
|
||||
->whereNull('merged_into_id')->whereNull('deleted_at')
|
||||
|
|
@ -204,7 +204,7 @@ class ContactController extends Controller
|
|||
|
||||
private function findByNameZip(): array
|
||||
{
|
||||
return DB::table('contacts')
|
||||
return DB::table('customer')
|
||||
->selectRaw('GROUP_CONCAT(id ORDER BY updated_at DESC, id DESC) as ids')
|
||||
->whereNotNull('name')->whereNotNull('firstname')
|
||||
->whereNotNull('zip')->where('zip', '!=', '')
|
||||
|
|
@ -228,8 +228,8 @@ class ContactController extends Controller
|
|||
// Reihenfolge wichtig: select() zuerst, dann withCount() — sonst überschreibt
|
||||
// select() die COUNT-Subqueries die withCount() per addSelect() eingetragen hat.
|
||||
$query = $showDeleted
|
||||
? Contact::onlyTrashed()->withoutGlobalScope('not_merged')->select('contacts.*')->withCount(['leads', 'bookings'])
|
||||
: Contact::select('contacts.*')->withCount(['leads', 'bookings']);
|
||||
? Contact::onlyTrashed()->withoutGlobalScope('not_merged')->select('customer.*')->withCount(['leads', 'bookings'])
|
||||
: Contact::select('customer.*')->withCount(['leads', 'bookings']);
|
||||
|
||||
// Zusatzfilter aus der UI (werden als extra GET-Parameter gesendet)
|
||||
if ($request->filled('filter_has_leads')) {
|
||||
|
|
@ -275,7 +275,7 @@ class ContactController extends Controller
|
|||
->orderColumn('deleted_at', 'customer.deleted_at $1')
|
||||
->filterColumn('id', function ($query, $keyword) {
|
||||
if ($keyword !== '') {
|
||||
$query->where('contacts.id', 'LIKE', '%' . $keyword . '%');
|
||||
$query->where('customer.id', 'LIKE', '%' . $keyword . '%');
|
||||
}
|
||||
})
|
||||
->filterColumn('name', function ($query, $keyword) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue