Add accessory and consumable specific checkin methods

This commit is contained in:
Marcus Moore 2024-07-24 14:17:49 -07:00
parent 7161b6416e
commit 44dbbeb608
No known key found for this signature in database

View file

@ -16,6 +16,7 @@ use App\Models\Consumable;
use App\Models\User;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Password;
@ -229,9 +230,9 @@ class BulkUsersController extends Controller
$this->logItemCheckinAndDelete($assets, Asset::class);
$this->logItemCheckinAndDelete($accessories, Accessory::class);
$this->logAccessoriesCheckin($accessories);
$this->logItemCheckinAndDelete($licenses, License::class);
$this->logItemCheckinAndDelete($consumables, Consumable::class);
$this->logConsumablesCheckin($consumables);
Asset::whereIn('id', $assets->pluck('id'))->update([
@ -291,6 +292,34 @@ class BulkUsersController extends Controller
}
}
private function logAccessoriesCheckin(Collection $accessories): void
{
foreach ($accessories as $accessory) {
$logAction = new Actionlog();
$logAction->item_id = $accessory->accessory_id;
$logAction->item_type = Accessory::class;
$logAction->target_id = $accessory->assigned_to;
$logAction->target_type = User::class;
$logAction->user_id = Auth::id();
$logAction->note = 'Bulk checkin items';
$logAction->logaction('checkin from');
}
}
private function logConsumablesCheckin(Collection $consumables): void
{
foreach ($consumables as $consumable) {
$logAction = new Actionlog();
$logAction->item_id = $consumable->consumable_id;
$logAction->item_type = Consumable::class;
$logAction->target_id = $consumable->assigned_to;
$logAction->target_type = User::class;
$logAction->user_id = Auth::id();
$logAction->note = 'Bulk checkin items';
$logAction->logaction('checkin from');
}
}
/**
* Save bulk-edited users
*