<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        $dynTagPermission = \App\Models\Permission::where('route','dynamictag.index')->first();
        if(!is_null($dynTagPermission))
            addChildPermission('Copy Dynamic Tag Template','1','web','0','0','all','5','dynamictag.clone',$dynTagPermission->id,'clone_dynamic_tag');
        \Illuminate\Support\Facades\DB::statement("UPDATE `mainmenu` SET `routes` = 'dynamictags||dynamictag/{id}/edit||dynamictag/add||dynamictag/templates||dynamictag/template/{id}/edit||dynamictag/template/add||dynamictag/template/{id}/use' WHERE `mainmenu`.`id` = 28;");
        \Illuminate\Support\Facades\DB::statement("UPDATE `mainmenu` SET `routes` = 'broadcasts||broadcast/{id}/edit||broadcast/add||broadcast/add/{id}||broadcast/schedule||spintags||dynamictags||dynamictag/{id}/edit||drips||drips/*||drip/group/view||drip/group/{id}/edit||drip/group/add||drip/add||splittests||splittest/{id}/edit||splittest/add||schedule/new/*||spintag/add||dynamictag/add||scheduled||broadcasts/schedule||spintag/{id}/edit||broadcast/create/{id}||drip/{id}/edit||scheduled/{type?}||campaign/evergreen||campaign/evergreen/{id}||campaign/evergreen/edit/{id}||spintag/templates||spintag/template/add||spintag/template/{id}/edit||dynamictag/templates||dynamictag/template/{id}/edit||dynamictag/template/add||dynamictag/template/{id}/use' WHERE `mainmenu`.`id` = 3;");

    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        \App\Models\Permission::where('route','dynamictag.clone')->delete();
        \Illuminate\Support\Facades\DB::statement("UPDATE `mainmenu` SET `routes` = 'dynamictags||dynamictag/{id}/edit||dynamictag/add' WHERE `mainmenu`.`id` = 28;");
        \Illuminate\Support\Facades\DB::statement("UPDATE `mainmenu` SET `routes` = 'broadcasts||broadcast/{id}/edit||broadcast/add||broadcast/add/{id}||broadcast/schedule||spintags||dynamictags||dynamictag/{id}/edit||drips||drips/*||drip/group/view||drip/group/{id}/edit||drip/group/add||drip/add||splittests||splittest/{id}/edit||splittest/add||schedule/new/*||spintag/add||dynamictag/add||scheduled||broadcasts/schedule||spintag/{id}/edit||broadcast/create/{id}||drip/{id}/edit||scheduled/{type?}||campaign/evergreen||campaign/evergreen/{id}||campaign/evergreen/edit/{id}||spintag/templates||spintag/template/add||spintag/template/{id}/edit' WHERE `mainmenu`.`id` = 3;");
    }
};
