Route::post(\"/{user}/{char_name}\", array(
\'as\' => \'char-profile-post\',
\'uses\' => \'ProfileController@postDropDownL
Laravel can absolutely send multiple variables to a view, and here's some code showing how I do it in a project of mine:
Route:
Route::get('play/{id}', array('before' => 'loggedin', 'uses' => 'GameController@confirmEntry'));
As you can see, in this route, I expect the variable id
to be passed to my controller.
Controller:
public function confirmEntry($id){
//stuff that doesn't matter
$data = array('puzzle' => $puzzle,
'user' => $user,
'wallet' => $wallet);
return View::make('game.solver-confirm', $data);
}
In the above example, since I list $id
as a parameter, and I have id
in my route, $id
will be set to whatever it was in the route. For instance, if I went to play/56
, $id
would be equal to 56
.
View:
@foreach ($puzzle->tile as $tile)
- a list gets made here
@endforeach
You can see in the controller, I passed $puzzle
(along with a few other variables) to the view, and then I call them just like you showed in my view.
Issues with yours:
The first issue I see is that you accept two variables from your route, and then overwrite them. That doesn't make much sense to me:
public function postDropDownList($user, $char_name) {
$user = Auth::user();
$char_name = Input::get('choose');
//more stuff here
}
Why bother passing $user
and $char_name
only to overwrite them?
That makes me thing that the issue you're having is because your data is structured poorly. I'd suggest doing a var_dump
or print_r
to see how $char_name
is actually being structured.
References:
http://us2.php.net/var_dump
http://us2.php.net/manual/en/function.print-r.php