Q:

Laravel : how to pass parameters to my view and display them in Form::text and Form::date?

I'm trying to make a view for editing fields. 
In fact I have two problems :
1) I get my data from my db with my controller, that's work, and I try to pass it to my view, that doesn't work...
2) I want to display these data in Form::text and Form::date, that doesn't work...
What I've in my controller :
public function edit($id)
    {
        $data = DB::connection('my-db')
            ->table('my-table')
            ->where('id', '=', $id)
            ->select('field1', 'field2')
            ->first();

        return view('my-view', compact('field1', 'field2'));
    }

I don't even know if compact in return view works like this
What I've in my view :
<div class="col-md-6">
  {!! Form::text(field1, "", ['id'=> 'idField', 'class' => 'form-control', 'placeholder' => 'Modify field']) !!}
</div>
<div class="col-md-2">
  {!! Form::date(field2, "", ['id'=> 'datetimepicker', 'class' => 'form-control']) !!}
</div>

I hope it's understandable, and thanks for your future answers :)

A:

public function edit($id)
{
    $data = DB::connection('my-db')
            ->table('my-table')
            ->where('id', '=', $id)
            ->select('field1', 'field2')
            ->first();

    $field1 = $data->field1; // intialize the $field1 variable 
    $field2 = $data->field2; // intialize the $field2 varialbe

    return view('my-view', compact('field1', 'field2'));
}

You were missing the $ sign before the variable name
Change field1 to $field1
<div class="col-md-6">
  {!! Form::text('field1', $field1, ['id'=> 'idField', 'class' => 'form-control', 'placeholder' => 'Modify field']) !!}
</div>
<div class="col-md-2">
  {!! Form::date('field2', $field2, ['id'=> 'datetimepicker', 'class' => 'form-control']) !!}
</div>

For more information, you can visit Laravel Form Collective Documentation

