mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-13 06:47:46 -08:00
Simplified the migration
This commit is contained in:
parent
9a1acced58
commit
be0e327221
|
@ -15,30 +15,15 @@ class FixZeroValuesForLocations extends Migration
|
||||||
*/
|
*/
|
||||||
public function up()
|
public function up()
|
||||||
{
|
{
|
||||||
$assets = Asset::where('location_id', '=', '0')->orWhere('rtd_location_id', '=', '0')->get();
|
App\Models\Asset::where('location_id', '=', '0')
|
||||||
$users = User::where('location_id', '=', '0')->get();
|
->update(['location_id' => null]);
|
||||||
|
|
||||||
foreach ($assets as $asset) {
|
App\Models\Asset::where('rtd_location_id', '=', '0')
|
||||||
|
->update(['rtd_location_id' => null]);
|
||||||
|
|
||||||
if ($asset->location_id == '0') {
|
App\Models\User::where('location_id', '0')
|
||||||
$asset->location_id = '';
|
->update(['location_id' => null]);
|
||||||
}
|
|
||||||
|
|
||||||
if ($asset->rtd_location_id == '0') {
|
|
||||||
$asset->rtd_location_id = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
$asset->save();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($users as $user) {
|
|
||||||
if ($user->location_id == '0') {
|
|
||||||
$user->location_id = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
$user->save();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue