0
    public function getValues(Request $request){
    $typ=$request->get('typ');
    $stellentyp=$request->get('stellentyp');
    $bereich=$request->get('bereich');
    return view('test.result',['typ' => $typ, 'stellentyp', $stellentyp, 'bereich', $bereich]);
}

this is my controller function now. Is it possible to get this view:

return view('test.$stellentyp',['typ' => $typ, 'stellentyp', $stellentyp, 'bereich', $bereich]);

i want that the user can select the "stellentyp" and then the view with that "stellentyp" should be shown

i dont know if its possible in laravel , but i know its posible in php

thank you! :)

3
  • 1
    AJAX would work for you. Commented Aug 28, 2018 at 10:00
  • This is also possible in laravel to return a view with it's parameters inside array like you mentioned. Commented Aug 28, 2018 at 10:01
  • Use "test.$stellentyp" instead of 'test.$stellentyp' Commented Aug 28, 2018 at 10:03

2 Answers 2

1

mb you want something like this?

return view('test.'.$stellentyp, ['typ' => $typ, 'stellentyp' => $stellentyp, 'bereich' => $bereich]);

change 'test.$stellentyp' to 'test.'.$stellentyp or "test.$stellentyp"

Sign up to request clarification or add additional context in comments.

6 Comments

i test it but my route doesnt work. Route::post('/$stellentyp', 'StartController@getValues')->name('user.$stellentyp');
@MonaMuhr How/why are routes involved now? That should be something like Route::post('/stelle/{stellentyp}'... laravel.com/docs/5.6/routing#route-parameters
Route::resource('user/start', 'StartController'); Route::post('user/'.$stellentyp,'StartController@getValues')->name('user.'.$stellentyp); these are my routes
@MonaMuhr it should be like Route::post('user/{stellentyp}','StartController@getValues') i think
@MonaMuhr try to open user/result page after changes
|
0

Try this

$view = 'test.'.$stellentyp;
return view($view,['typ' => $typ, 'stellentyp', $stellentyp, 'bereich', $bereich]);

2 Comments

how should i change the route?
No need to change route just pass params

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.