Cleand migration and updated with new enums

This commit is contained in:
noah.lancien 2023-04-11 12:28:33 +00:00
parent aa381ac61b
commit 9a49686f93

View file

@ -1,7 +1,7 @@
<?php
use App\Models\Ticket;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
class ChangeTicketsStatus extends Migration
{
@ -12,33 +12,18 @@ class ChangeTicketsStatus extends Migration
*/
public function up()
{
$tickets = DB::table('tickets')->get();
collect($tickets)->map(function (object $ticket) {
switch ($ticket->status) {
case 3:
DB::table('tickets')->where('id', $ticket->id)
->update(['status' => 18]);
break;
case 4:
DB::table('tickets')->where('id', $ticket->id)
->update(['status' => 18]);
break;
case 5:
DB::table('tickets')->where('id', $ticket->id)
->update(['status' => 18]);
break;
case 7:
DB::table('tickets')->where('id', $ticket->id)
->update(['status' => 18]);
break;
case 10:
DB::table('tickets')->where('id', $ticket->id)
->update(['status' => 13]);
break;
default:
break;
} //end switch
});
Ticket::whereIn('status', [4, 5, 7, 10])
->update(['status' => 3]);
Ticket::where('status', 9)
->update(['status' => 4]);
Ticket::where('status', 17)
->update(['status' => 5]);
Ticket::where('status', 12)
->update(['status' => 6]);
Ticket::where('status', 13)
->update(['status' => 7]);
Ticket::where('status', 15)
->update(['status' => 8]);
}
/**
@ -48,6 +33,5 @@ class ChangeTicketsStatus extends Migration
*/
public function down()
{
//
}
}