mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-24 21:24:13 -08:00
Added created_by
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
6699995972
commit
02a29c71ef
|
@ -97,6 +97,9 @@ class AssetMaintenancesController extends Controller
|
||||||
case 'status_label':
|
case 'status_label':
|
||||||
$maintenances = $maintenances->OrderStatusName($order);
|
$maintenances = $maintenances->OrderStatusName($order);
|
||||||
break;
|
break;
|
||||||
|
case 'created_by':
|
||||||
|
$maintenances = $maintenances->OrderByCreatedBy($order);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
$maintenances = $maintenances->orderBy($sort, $order);
|
$maintenances = $maintenances->orderBy($sort, $order);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -92,6 +92,9 @@ class ConsumablesController extends Controller
|
||||||
case 'supplier':
|
case 'supplier':
|
||||||
$consumables = $consumables->OrderSupplier($order);
|
$consumables = $consumables->OrderSupplier($order);
|
||||||
break;
|
break;
|
||||||
|
case 'created_by':
|
||||||
|
$consumables = $consumables->OrderByCreatedBy($order);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
// This array is what determines which fields should be allowed to be sorted on ON the table itself.
|
// This array is what determines which fields should be allowed to be sorted on ON the table itself.
|
||||||
// These must match a column on the consumables table directly.
|
// These must match a column on the consumables table directly.
|
||||||
|
|
|
@ -117,7 +117,7 @@ class LicensesController extends Controller
|
||||||
$licenses = $licenses->leftJoin('companies', 'licenses.company_id', '=', 'companies.id')->orderBy('companies.name', $order);
|
$licenses = $licenses->leftJoin('companies', 'licenses.company_id', '=', 'companies.id')->orderBy('companies.name', $order);
|
||||||
break;
|
break;
|
||||||
case 'created_by':
|
case 'created_by':
|
||||||
$licenses = $licenses->OrderCreatedBy($order);
|
$licenses = $licenses->OrderByCreatedBy($order);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$allowed_columns =
|
$allowed_columns =
|
||||||
|
|
|
@ -65,6 +65,10 @@ class AssetMaintenancesTransformer
|
||||||
'asset_maintenance_time' => $assetmaintenance->asset_maintenance_time,
|
'asset_maintenance_time' => $assetmaintenance->asset_maintenance_time,
|
||||||
'completion_date' => Helper::getFormattedDateObject($assetmaintenance->completion_date, 'date'),
|
'completion_date' => Helper::getFormattedDateObject($assetmaintenance->completion_date, 'date'),
|
||||||
'user_id' => ($assetmaintenance->admin) ? ['id' => $assetmaintenance->admin->id, 'name'=> e($assetmaintenance->admin->getFullNameAttribute())] : null,
|
'user_id' => ($assetmaintenance->admin) ? ['id' => $assetmaintenance->admin->id, 'name'=> e($assetmaintenance->admin->getFullNameAttribute())] : null,
|
||||||
|
'created_by' => ($assetmaintenance->adminuser) ? [
|
||||||
|
'id' => (int) $assetmaintenance->adminuser->id,
|
||||||
|
'name'=> e($assetmaintenance->adminuser->present()->fullName()),
|
||||||
|
] : null,
|
||||||
'created_at' => Helper::getFormattedDateObject($assetmaintenance->created_at, 'datetime'),
|
'created_at' => Helper::getFormattedDateObject($assetmaintenance->created_at, 'datetime'),
|
||||||
'updated_at' => Helper::getFormattedDateObject($assetmaintenance->updated_at, 'datetime'),
|
'updated_at' => Helper::getFormattedDateObject($assetmaintenance->updated_at, 'datetime'),
|
||||||
'is_warranty'=> $assetmaintenance->is_warranty,
|
'is_warranty'=> $assetmaintenance->is_warranty,
|
||||||
|
|
|
@ -174,7 +174,7 @@ class AssetMaintenance extends Model implements ICompanyableChild
|
||||||
* @author A. Gianotto <snipe@snipe.net>
|
* @author A. Gianotto <snipe@snipe.net>
|
||||||
* @version v3.0
|
* @version v3.0
|
||||||
*/
|
*/
|
||||||
public function admin()
|
public function adminuser()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(\App\Models\User::class, 'user_id')
|
return $this->belongsTo(\App\Models\User::class, 'user_id')
|
||||||
->withTrashed();
|
->withTrashed();
|
||||||
|
@ -278,4 +278,12 @@ class AssetMaintenance extends Model implements ICompanyableChild
|
||||||
->leftjoin('status_labels as maintained_asset_status', 'maintained_asset_status.id', '=', 'maintained_asset.status_id')
|
->leftjoin('status_labels as maintained_asset_status', 'maintained_asset_status.id', '=', 'maintained_asset.status_id')
|
||||||
->orderBy('maintained_asset_status.name', $order);
|
->orderBy('maintained_asset_status.name', $order);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Query builder scope to order on the user that created it
|
||||||
|
*/
|
||||||
|
public function scopeOrderByCreatedBy($query, $order)
|
||||||
|
{
|
||||||
|
return $query->leftJoin('users as admin_sort', 'asset_maintenances.created_by', '=', 'admin_sort.id')->select('asset_maintenances.*')->orderBy('admin_sort.first_name', $order)->orderBy('admin_sort.last_name', $order);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -451,4 +451,9 @@ class Consumable extends SnipeModel
|
||||||
{
|
{
|
||||||
return $query->leftJoin('suppliers', 'consumables.supplier_id', '=', 'suppliers.id')->orderBy('suppliers.name', $order);
|
return $query->leftJoin('suppliers', 'consumables.supplier_id', '=', 'suppliers.id')->orderBy('suppliers.name', $order);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function scopeOrderByCreatedBy($query, $order)
|
||||||
|
{
|
||||||
|
return $query->leftJoin('users as users_sort', 'consumables.created_by', '=', 'users_sort.id')->select('consumables.*')->orderBy('users_sort.first_name', $order)->orderBy('users_sort.last_name', $order);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue