mardi 6 mars 2018

Laravel - Get items from session array

I'm making a step program and therefore I wanted to use sessions. I have a form which allows the user to fill in some information and then the input values will be put in a session array called "basic_settins" like this

public function saveSettings(Request $request, Product $products)
{
    $request->session()->push('basic_settings', $request->input());


    return redirect('/themes');
}

But how can I get a specific item from that array and display it for instance in my view? By using something like this: in an input field.

The view looks like this:

@extends('layouts.app')

@section('content')
<div class="container">
    <div class="row">
        <div class="col-md-12">
            <form method="POST" action="">
                <div class="row">
                    <div class="col-md-12">
                        <button class="btn btn-primary mb-3 float-right">Next</button>
                    </div>
                </div>

                <div class="card z-depth-2" style="border-radius: 7px;">
                    <div class="card-body">
                        <input type="hidden" name="user_id" value="">
                        
                        <div class="form-group">
                            <label for="store_name">Store name</label>
                            <input type="text" class="form-control" placeholder="Store name" id="store_name" name="store_name" value="" required>

                        </div>
                        <div class="form-group">
                            <label for="company name">Company name</label>
                            <input type="text" class="form-control" placeholder="Company name" id="company_name" name="company_name" value="" required>

                        </div>
                        <div class="form-group">
                            <label for="company_tel">Company phonenumber</label>
                            <input type="text" class="form-control" placeholder="Company Phonenumber" id="company_tel" name="company_tel" value="" required>

                        </div>
                    </div>
                </div>
            </form>
        </div>

    </div>
</div>
@endsection

When I dd the request by doing this: $data = $request->session()->all(); and then dd($data);

I get the following result:

enter image description here

How can I make this work? Thanks in advance!



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

Aucun commentaire:

Enregistrer un commentaire