deyaamuhammad deyaamuhammad - 3 months ago 8
SQL Question

how to find and update multiple records?

Now i have this table called


i use it to save my project configurations

And i use this Eloquent method to fetch table?

$config = Config::pluck('value','name')->all();

The question is How to update the whole table from an array?

[_method] => PUT
[_token] => FvpYFD6GeVaNIHTOwquycLlarhLuNoL6MiLwSqkJ
[site_title] => title
[site_description] => description
[site_keywords] => keyword1,keyword2
[taxonomy_paginate] => 20
[comment_disqusEnable] => on
[comment_disqusUsername] => username

Thanks in Advance.


You can update multiple records using a loop. For example:

$configs = Config::all();

foreach ($configs as $config) {
  $config->name = 'new name';
  $config->value = 'new value';