Просмотр файла database/migrations/2023_05_15_031832_add_app_name_to_settings.php

Размер файла: 1.1Kb
<?php

use App\Models\Setting;

return new class
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up(): void
    {
        foreach ($this->seed() as $seed) {
            Setting::query()->create($seed);
        }

    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down(): void
    {
        foreach ($this->seed() as $seed) {
            Setting::query()
                ->where('name', $seed['name'])
                ->delete();
        }
    }

    /**
     * Seed
     *
     * @return array[]
     */
    private function seed(): array
    {
        return [
            ['name' => 'app.name', 'value' => 'Motorcms.ru'],
            ['name' => 'app.url', 'value' => 'https://motorcms.ru'],
            ['name' => 'main.confirm_email', 'value' => false],
            ['name' => 'mailer.dsn', 'value' => 'smtps://login:[email protected]:465'],
            ['name' => 'mailer.from_email', 'value' => '[email protected]'],
            ['name' => 'mailer.from_name', 'value' => 'Администратор'],
        ];
    }
};