MonaMuhr
MonaMuhr

Reputation: 185

laravel view with a variable

    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! :)

Upvotes: 0

Views: 126

Answers (2)

user8824269
user8824269

Reputation:

Try this

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

Upvotes: 0

Vlad  Chornyi
Vlad Chornyi

Reputation: 268

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"

Upvotes: 1

Related Questions