Q:

Laravel forms with models

I have this code for my form and it works well:
    <div class="form-group">

        <select class="form-control" id="exampleSelect1">
        <option>Assign</option>
        @foreach ($projects as $project)
        <option>{{ $project->name }} </option>

        @endforeach
        </select>
    </div>

but what I'm trying to do is this with a contact form:
        <div class="form-group">
            {!! Form::label('name', 'Project') !!}
            {!! Form::select (@theforeach with the values :c ) !!}}
        </div>

I'm using the use App\Http\Requests\ContactFormRequest; and I have been searching the way of doing it but there is to few examples on google.

A:

If you want your select options to works, you need to call it properly,
From controller,
 // Example : This is for single view page

 $list_of_options = Products::pluck('name','id');
 return view('your_view_name',compact('list_of_options')); 

// Example : If you want select dropdown in all page ( within the controller views)   then,

use Illuminate\Support\Facades\View;

public function __construct(){
   View::share('list_of_options',Products::pluck('name','id'));  
}

Now in blade,
  {{ dd($list_of_options); }} // Check if the values are comming in proper formate

  {!! Form::select('name_of_the_select', $list_of_options, null ,[
         'class' => 'form-control',
         'id'    => 'name_of_the_select'
      ]);
   !!}

Here is the button with <i> or <span> inside of it :-
{{ Form::button(
    '<span class="fa fa-play fa-1x"></span>',
        [
            'class'=>'btn btn-info',
            'type'=>'button'
        ])
    }}

From your question ( UPDATED )
<div class="form-group">
{!! Form::label('exampleSelect1', 'Project') !!}
{!! Form::select('projects', $projects, null ,[
             'class'       => 'form-control',
             'id'          => 'exampleSelect1',
             'placeholder' => 'Please select project'

          ]);
       !!}
    </div>

I hope this helps. :)

