I'm trying to find the correct way to lay this out in laravel so that I can hit one GET route which calls a single function, but within that function I want to use data from a mysql table to determine which blade to show.
Say this URL is visited with a query string parameter:
www.testsite.com?email=testEmail.com
I hit this route (But not sure how to accept the parameter)
Route::get('register', 'Data\DataController@DataForm')
->name('Data.register');
I have a mysql table called dataTable
set up like so
email | type
-------------------------
test1@mail.com A
test2@mail.com B
test3@mail.com C
What's the best way to incorporate the email parameter so that I can hit the single route and single function, then use the email/type columns from mysql to determine the appropriate blade to show?
public function DataForm(Request $request)
{
//query table based on query string parameter 'email'
$email = dataTable::where('email', /*email parameter?*/)->first();
if($email['type']== A){
return view('data.typeA');
}elseif($email['type']== B){
return view('data.typeB');
}elseif($email['type']== C){
return view('data.typeC');
}
}