Laravel update method not working
<p>I am trying to update my db but it does not work properly.</p>

<p>I build an update method, the problem is that it keeps updating all records with the product_id, whereas it should update each record 
I have for instance 10 records with different values in my db.</p>

<p>If I run the script all records get the first value from the input field.</p>

<p>How do I make it work correctly ?</p>

<p>A little scretch of how my db, looks like this:</p>

<pre><code>id      |       product_id       |       short_name      |      input_video
___________________________________________________________________________
 1      |            49          |            de         |       c:\...
 2      |            49          |            en         |       c:\...
 3      |            49          |            tr         |       c:\...
 4      |            49          |            dr         |       c:\...
</code></pre>

<p>If I run my code (picking de) it looks like this:</p>

<pre><code>id      |       product_id       |       short_name      |      input_video
___________________________________________________________________________
 1      |            49          |            de         |       c:\...
 2      |            49          |            de         |       c:\...
 3      |            49          |            de         |       c:\...
 4      |            49          |            de         |       c:\...
</code></pre>

<p>code:</p>

<pre><code>    # save language selection
    $lsCounter = 0;
    $langSelecName = $request-&gt;input('language_selection');
    $langSelecFile = $request-&gt;file('language_selection');
    if($langSelecName)
    {
        $projectLangPath = $Path . "language";

        foreach($langSelecName as $langSelecNameKey =&gt; $langSelecNameValue)
        {
            if($langSelecFile[$lsCounter]['input_vid_lang'] != null)
            {
                $langVidFileName = $langSelecFile[$lsCounter]['input_vid_lang']-&gt;getClientOriginalName();

                $languages = new Language();
                $languages['short_name']  = $langSelecNameValue;
                $languages['input_video'] = $projectLangPath . '\\' . $langVidFileName;

                $languages-&gt;product()-&gt;associate($product);

                $langSelecName = $request-&gt;input('language_selection');

                $langData = [
                    'short_name' =&gt; $languages['short_name'],
                    'input_video' =&gt; $languages['input_video']
                ];

                $intProductID = intval($productID);

                $findLang = $languages-&gt;where('product_id', $intProductID);

                $productID = $data['id'];

                if($findLang-&gt;update($langData))
                {
                    $langSelecFile[$lsCounter]['input_vid_lang']-&gt;move($projectLangPath, $langVidFileName);
                }
            }

            $lsCounter++;
        }
    }
</code></pre>

<p>My where clause is probably not right, but I am not sure how to fix it.</p>

<p><strong>Edit</strong>
my Model:</p>

<pre><code>&lt;?php

    class Language extends Model
    {

        protected $table = 'products_languages';

        protected $fillable = ['product_id', 'short_name', 'input_video'];

        public function product()
        {
            return $this-&gt;belongsTo('App\Product', 'product_id');
        }

    }
</code></pre>

<p><strong>Edit</strong></p>

<p>View:</p>

<pre><code>            &lt;fieldset class="form-group"&gt;
                &lt;select class="form-control" id="language_selection" name="language_selection[]" multiple&gt;
                    @foreach($languages as $languageKey =&gt; $languageValue)
                        &lt;option value="&lt;?php echo $languageValue-&gt;short_name; ?&gt;"&gt;&lt;?php echo $languageValue-&gt;name; ?&gt;&lt;/option&gt;
                    @endforeach
                &lt;/select&gt;
            &lt;/fieldset&gt;
            @if($type == "edit")
                &lt;input name="id" type="hidden" value="{{ $productId }}"&gt;
                @if($languagesCount &gt; 0)
                    @foreach($languages as $languagesKey =&gt; $languagesValue)
                        &lt;?php $i = 0 ?&gt;
                            &lt;span class="btn btn-primary btn-file lang-edit"&gt;{{ strtoupper($languagesValue-&gt;short_name) }}&lt;/span&gt;
                        &lt;?php $i++ ?&gt;
                    @endforeach
                @endif
            @endif
</code></pre>