Merge pull request #11169 from inietov/fixes/user_update_from_import_location_in_assets
Fixes Asset location doesn't change when assigned user's location change via importer
This commit is contained in:
commit
c3b644797e
1 changed files with 7 additions and 0 deletions
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Importer;
|
namespace App\Importer;
|
||||||
|
|
||||||
|
use App\Models\Asset;
|
||||||
use App\Models\Department;
|
use App\Models\Department;
|
||||||
use App\Models\Setting;
|
use App\Models\Setting;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
@ -79,6 +80,12 @@ class UserImporter extends ItemImporter
|
||||||
$this->log('Updating User');
|
$this->log('Updating User');
|
||||||
$user->update($this->sanitizeItemForUpdating($user));
|
$user->update($this->sanitizeItemForUpdating($user));
|
||||||
$user->save();
|
$user->save();
|
||||||
|
|
||||||
|
// Update the location of any assets checked out to this user
|
||||||
|
Asset::where('assigned_type', User::class)
|
||||||
|
->where('assigned_to', $user->id)
|
||||||
|
->update(['location_id' => $user->location_id]);
|
||||||
|
|
||||||
// \Log::debug('UserImporter.php Updated User ' . print_r($user, true));
|
// \Log::debug('UserImporter.php Updated User ' . print_r($user, true));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue