Support the ongoing development of Laravel.io →
Forms Laravel
Last updated 3 months ago.
0

I think just a little bit of flow logic needs to be put in to make this work.

The code below would give the user a form where they put in their reference number, we look up that number and get any additional info from the design and then redirect to the correct url.

// form
<form action="/findMyRef" method="post">
    <input type="text" name="number">
</form>

// route
Route::post('/findMyRef', '[email protected]');

// DesignController
public function route(Request $request)
{
    $design = Design::query()
        ->where('reference_number', $request->number)
        ->firstOrFail();

    return redirect('/d/' . $design->slug );
}
Last updated 2 years ago.
0

Hi Ben, Thank you very much for providing that, totally makes sense and will give that a try. I did post the same question on Reddit and was advised to use Javascript to transfer the ref number directly in to the URL and query it BUT I am liking this idea a whole lot better, also helps as trying to avoid any unnecessary javascript on the project. Thanks again for the insight, hugely appreciated. Chris

1

Works perfectly and will make sense to do it this way as I can validate the input too. Thanks @Ben

0

Sign in to participate in this thread!

LoadForge

Your banner here too?

Chris Chris error500 Joined 16 Jan 2020

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2022 Laravel.io - All rights reserved.