mardi 29 septembre 2015

Pass data from controller to view laravel 5

Controller

public function codingPuzzleProcess()
{

    $word     = Input::get('word');
    $length   = strlen($word);


    return Redirect::to('/coding-puzzle')
        ->with('word', $word )
        ->with('length', $length )
        ->with('success','Your word was submit succesfully!');

}


View

I tried to access those data in my blade view like this

{!!$word or '' !!} | {!!$length or '' !!}

and I got nothing printing. I'm sure that my

$word = 'love' with length of 4

Any hints / suggestion on this will be much appreciated !


Route

Route::get('/coding-puzzle', 'CodeController@codingPuzzle');
Route::post('/coding-puzzle/process', 'CodeController@codingPuzzleProcess');


Form / Blade

{!! Form::open(array('url' => '/coding-puzzle/process', 'class' => '', 'role' =>'form')) !!}

{{-- Text --}}
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 form-group form-row">
  <input required type="text" class="normal" placeholder="Enter Word" name="word"
  value="{{Request::old('word')}}">
  {!! $errors->first('word','<p style="color:#EE6593 !important; text-align: center;">:message</p>') !!}
</div>

<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<input type="submit" id="submit" name="send" value="Get rank" class="button">
</div>

{!! Form::close();!!}



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1VkZ2gP
via IFTTT

Aucun commentaire:

Enregistrer un commentaire