We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
Conditions | 2 |
Paths | 2 |
Total Lines | 25 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
25 | public function replaceModels($table_name) |
||
26 | { |
||
27 | Log::info('Replacing BackpackUser model in '.$table_name); |
||
28 | |||
29 | // if you've ended up with duplicate entries (both for App\User and App\Models\BackpackUser) |
||
30 | // we can just delete them |
||
31 | $userEntries = DB::table($table_name) |
||
32 | ->where('model_type', "App\User") |
||
33 | ->get(); |
||
34 | |||
35 | foreach ($userEntries as $entry) { |
||
36 | DB::table($table_name) |
||
37 | ->where('role_id', $entry->role_id) |
||
38 | ->where('model_type', 'App\Models\BackpackUser') |
||
39 | ->where('model_id', $entry->model_id) |
||
40 | ->delete(); |
||
41 | } |
||
42 | |||
43 | // for the rest of them, we can just replace the BackpackUser model with User |
||
44 | DB::table($table_name) |
||
45 | ->where('model_type', "App\Models\BackpackUser") |
||
46 | ->update([ |
||
47 | 'model_type' => "App\User", |
||
48 | ]); |
||
49 | } |
||
50 | } |
||
51 |