How to show categories in product creating page in Laravel
<p>I have this form in the Laravel admin backend which adds new products to database.</p>

<p><code>productCreate.blade.php</code></p>

<pre><code> {{ Form::open(['files' =&gt; true]) }}
&lt;div class="form-group"&gt;
    &lt;label for="title" class="control-block"&gt;Product title:&lt;/label&gt;
    {{ Form::text('title', null, ['class' =&gt; 'form-control']) }}
&lt;/div&gt;

&lt;div class="form-group"&gt;
    &lt;label for="title" class="control-block"&gt;Product description:&lt;/label&gt;
    {{ Form::textarea('description', null, ['class' =&gt; 'form-control']) }}
    &lt;span class="help-block"&gt;HTML is allowed.&lt;/span&gt;
&lt;/div&gt;

&lt;div class="form-group"&gt;
    &lt;label for="title" class="control-block"&gt;Product price:&lt;/label&gt;
    {{ Form::text('price', null, ['class' =&gt; 'form-control']) }}
&lt;/div&gt;

&lt;div class="form-group"&gt;
    &lt;label for="title" class="control-block"&gt;Assign Product to Category:&lt;/label&gt;
    &lt;select class="form-control"&gt;
        &lt;option value="one"&gt;Category 1&lt;/option&gt;
        &lt;option value="two"&gt;Category 2&lt;/option&gt;
        &lt;option value="three"&gt;Category 3&lt;/option&gt;
        &lt;option value="four"&gt;Category 4&lt;/option&gt;
        &lt;option value="five"&gt;Category 5&lt;/option&gt;
    &lt;/select&gt;
&lt;/div&gt;

&lt;div class="form-group"&gt;
    &lt;label for="title" class="control-block"&gt;Product image:&lt;/label&gt;
    {{ Form::file('image', ['class' =&gt; 'form-control']) }}
&lt;/div&gt;

&lt;hr /&gt;

&lt;button type="submit" class="btn btn-primary"&gt;Create new product&lt;/button&gt;

{{ Form::close() }}
</code></pre>

<p>My question is how to show this select/options values from database. I want to be able to assign products to categories. Where I should make query and how to add them here in the view?</p>

<p>In admincontroller i have functions for product creation which load the view</p>

<pre><code>public function productsCreate() {
    return View::make('site.admin.products_create');
}
</code></pre>

<p>and I tried to make it like this</p>

<pre><code>public function productsCreate() {
    $categories = Categories::paginate(15);
        return View::make('site.admin.products_create', [
            'categories' =&gt; $categories
        ]);
    //return View::make('site.admin.products_create');
}
</code></pre>

<p>but then I got message</p>

<pre><code>production.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Cannot redeclare AdminController::productsCreate() ...
</code></pre>

<p>So how exactly I can query database table categories and show categories in the form?</p>

<p>May be because I already have categories selection in admin controller?</p>

<pre><code>public function categories() {
    $categories = Categories::all();
    return View::make('site.admin.categories', [
        'categories' =&gt; $categories
    ]);
}

public function productsCreate() {
//      $categories = Categories::paginate(15); 

        return View::make('site.admin.products_create', [
            'categories' =&gt; $categories
        ]);
    //return View::make('site.admin.products_create');
}
</code></pre>