55 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			PHP
		
	
	
	
			
		
		
	
	
			55 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			PHP
		
	
	
	
| <?php
 | |
| 
 | |
| use App\Form\Models\Form;
 | |
| use Illuminate\Database\Migrations\Migration;
 | |
| use Illuminate\Database\Schema\Blueprint;
 | |
| use Illuminate\Support\Facades\DB;
 | |
| use Illuminate\Support\Facades\Schema;
 | |
| 
 | |
| return new class extends Migration
 | |
| {
 | |
|     /**
 | |
|      * Run the migrations.
 | |
|      *
 | |
|      * @return void
 | |
|      */
 | |
|     public function up()
 | |
|     {
 | |
|         foreach (DB::table('forms')->get() as $event) {
 | |
|             $config = json_decode($event->config);
 | |
|             $config->sections = array_map(function ($section) {
 | |
|                 $section->fields = array_map(function ($field) {
 | |
|                     $field->hint = '';
 | |
|                     return $field;
 | |
|                 }, $section->fields);
 | |
| 
 | |
|                 return $section;
 | |
|             }, $config->sections);
 | |
|             DB::table('forms')->where('id', $event->id)->update(['config' => json_encode($config)]);
 | |
|         }
 | |
| 
 | |
|         foreach (DB::table('formtemplates')->get() as $event) {
 | |
|             $config = json_decode($event->config);
 | |
|             $config->sections = array_map(function ($section) {
 | |
|                 $section->fields = array_map(function ($field) {
 | |
|                     $field->hint = '';
 | |
|                     return $field;
 | |
|                 }, $section->fields);
 | |
| 
 | |
|                 return $section;
 | |
|             }, $config->sections);
 | |
|             DB::table('formtemplates')->where('id', $event->id)->update(['config' => json_encode($config)]);
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * Reverse the migrations.
 | |
|      *
 | |
|      * @return void
 | |
|      */
 | |
|     public function down()
 | |
|     {
 | |
|         //
 | |
|     }
 | |
| };
 |