mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-10 23:54:12 -08:00
Merge branch 'develop'
This commit is contained in:
commit
bbe9df306b
|
@ -17,6 +17,7 @@ class ReNormalizeLastAudit extends Migration
|
||||||
{
|
{
|
||||||
|
|
||||||
if (Schema::hasColumn('assets', 'last_audit_date')) {
|
if (Schema::hasColumn('assets', 'last_audit_date')) {
|
||||||
|
|
||||||
// Grab the latest info from the Actionlog table where the action is 'audit'
|
// Grab the latest info from the Actionlog table where the action is 'audit'
|
||||||
$audits = Actionlog::selectRaw('MAX(created_at) AS created_at, item_id')
|
$audits = Actionlog::selectRaw('MAX(created_at) AS created_at, item_id')
|
||||||
->where('action_type', 'audit')
|
->where('action_type', 'audit')
|
||||||
|
@ -27,10 +28,13 @@ class ReNormalizeLastAudit extends Migration
|
||||||
|
|
||||||
if ($audits) {
|
if ($audits) {
|
||||||
foreach ($audits as $audit) {
|
foreach ($audits as $audit) {
|
||||||
$assets = Asset::where('id', $audit->item_id)->first();
|
$asset = Asset::where('id', $audit->item_id)->withTrashed()->first();
|
||||||
$assets->last_audit_date = $audit->created_at;
|
if ($asset) {
|
||||||
$assets->unsetEventDispatcher();
|
$asset->last_audit_date = $audit->created_at;
|
||||||
$assets->save();
|
$asset->unsetEventDispatcher();
|
||||||
|
$asset->save();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue