feat: multi-tenant architecture and tenant isolation changes
This commit is contained in:
@@ -44,6 +44,20 @@ class ContactController extends Controller
|
||||
$perPage = $request->get('per_page', 10);
|
||||
$contacts = $query->paginate($perPage)->withQueryString();
|
||||
|
||||
// Attach matching Inquiry details if available
|
||||
$contacts->getCollection()->transform(function ($contact) {
|
||||
$inquiry = \App\Models\Inquiry::where('email', $contact->email)->first();
|
||||
if ($inquiry) {
|
||||
$contact->company_name = $inquiry->company_name;
|
||||
$contact->desired_subdomain = $inquiry->desired_subdomain;
|
||||
$contact->employee_count = $inquiry->employee_count;
|
||||
$contact->requested_features = $inquiry->requested_features ?? [];
|
||||
$contact->inquiry_notes = $inquiry->notes;
|
||||
$contact->payment_reference = $inquiry->payment_reference;
|
||||
}
|
||||
return $contact;
|
||||
});
|
||||
|
||||
return Inertia::render('contacts/index', [
|
||||
'contacts' => $contacts,
|
||||
'filters' => $request->only(['search', 'sort_field', 'sort_direction', 'per_page'])
|
||||
@@ -108,9 +122,13 @@ class ContactController extends Controller
|
||||
public function destroy(Contact $contact)
|
||||
{
|
||||
if (Auth::user()->can('delete-contacts')) {
|
||||
if ($contact->email) {
|
||||
\App\Models\Inquiry::where('email', $contact->email)->delete();
|
||||
}
|
||||
|
||||
$contact->delete();
|
||||
|
||||
return redirect()->back()->with('success', 'Contact deleted successfully.');
|
||||
return redirect()->back()->with('success', 'Contact and associated inquiry deleted successfully from database.');
|
||||
} else {
|
||||
return redirect()->back()->with('error', __('Permission Denied.'));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user