Skip to content

Commit

Permalink
Evaluate if the asset was assigned to a different user than current t…
Browse files Browse the repository at this point in the history
…arget to log a checkin event
  • Loading branch information
inietov committed Oct 25, 2023
1 parent d93e399 commit 7ed58a1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/Importer/AssetImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
use App\Models\Asset;
use App\Models\AssetModel;
use App\Models\Statuslabel;
use App\Models\User;
use App\Events\CheckoutableCheckedIn;
use Illuminate\Support\Facades\Auth;
use Carbon\Carbon;

class AssetImporter extends ItemImporter
Expand Down Expand Up @@ -142,6 +145,10 @@ public function createAssetIfNotExists(array $row)
//-- user_id is a property of the abstract class Importer, which this class inherits from and it's setted by
//-- the class that needs to use it (command importer or GUI importer inside the project).
if (isset($target)) {
if ($asset->assigned_to != $target->id){
event(new CheckoutableCheckedIn($asset, User::find($asset->assigned_to), Auth::user(), $asset->notes, date('Y-m-d H:i:s')));
}

$asset->fresh()->checkOut($target, $this->user_id, date('Y-m-d H:i:s'), null, $asset->notes, $asset->name);
}

Expand Down

0 comments on commit 7ed58a1

Please sign in to comment.