In my Laravel 5.7 app, I currently browse to URLs such as https://example.com/admin/contact?q=john@example.com using the "q" param so that I can search the Contacts table directly without needing to type into the DataTables ajax search field.
This works well except that I'd prefer it to bounce directly to the edit page (for exact matches of only 1 result).
In my ContactCrudController setup(), I have:
$q = $this->request->query->get('q');
if ($q) {// if there is an exact email match, redirect to the Edit page of that Contact.
$matchingContact = \App\Models\Contact::where('emailAddress', $q)->first();
if ($matchingContact) {
return redirect(url('/admin/contact/' . $matchingContact->id . '/edit'));
}
}
But this doesn't work because setup() doesn't expect a return redirect().
How can I achieve my goal?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire