mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 21:54:14 -08:00
Add accessory and consumable specific checkin methods
This commit is contained in:
parent
7161b6416e
commit
44dbbeb608
|
@ -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
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue