Skip to content

Commit

Permalink
Merge pull request #773 from portabilis/settings
Browse files Browse the repository at this point in the history
[2.6] Evita sobrescrever configurações já existentes
  • Loading branch information
edersoares authored Jul 21, 2021
2 parents 1754879 + 9ed26cc commit bd49655
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

use App\Setting;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class PopulateSettingsTable extends Migration
{
Expand Down Expand Up @@ -112,11 +110,14 @@ public function up()
'legacy.report.remote_factory.password' => null,
'legacy.report.remote_factory.logo_name' => null,
];

collect($settings)->each(function ($value, $key) {
Setting::query()->updateOrCreate([
if (Setting::query()->where('key', $key)->exists()) {
return;
}

Setting::query()->create([
'key' => $key,
], [
'value' => $value,
]);
});
Expand All @@ -129,6 +130,6 @@ public function up()
*/
public function down()
{
DB::table('settings')->delete();
Setting::query()->truncate();
}
}

0 comments on commit bd49655

Please sign in to comment.