Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
7588038
first round of revert formatting
JonasGoseberg Dec 4, 2025
2a8e610
second round of revert formatting
JonasGoseberg Dec 5, 2025
9cec70a
Merge branch 'develop' into SIT-214-revert-only-formatting-changes
JonasGoseberg Dec 5, 2025
098f25c
third round of revert formatting
JonasGoseberg Dec 5, 2025
d0ae9df
fourth round of revert formatting
JonasGoseberg Dec 5, 2025
a950fde
revert formatting related to asset.php
JonasGoseberg Dec 5, 2025
fd6ebb7
fifth round of revert formatting
JonasGoseberg Dec 5, 2025
0d35cf7
next round of reverting formatting
JonasGoseberg Dec 5, 2025
25eec1d
next round of revert formatting
JonasGoseberg Dec 5, 2025
32052b9
more code formatting stuff
JonasGoseberg Dec 5, 2025
6a60271
reformatted x-select.blade
JonasGoseberg Dec 5, 2025
24e6f6c
reverted some files
JonasGoseberg Dec 8, 2025
fbe983f
reverted formatting of hardware/index
JonasGoseberg Dec 8, 2025
4f69c2e
more formatting stuff
JonasGoseberg Dec 8, 2025
8bdea04
reverted assetscontroller
JonasGoseberg Dec 8, 2025
87bbd30
more reverting stuff
JonasGoseberg Dec 8, 2025
52e61e0
reverting formatting stuff
JonasGoseberg Dec 8, 2025
473e5a5
next round of reverting
JonasGoseberg Dec 8, 2025
4a98d42
some more formatting stuff
JonasGoseberg Dec 8, 2025
504ecb0
some more formatting
JonasGoseberg Dec 8, 2025
7cf9032
fixed selectlistTransformer
JonasGoseberg Dec 8, 2025
48fba49
Merge branch 'develop' into SIT-214-revert-only-formatting-changes
JonasGoseberg Dec 8, 2025
e473897
Merge branch 'develop' into SIT-214-revert-only-formatting-changes
JonasGoseberg Dec 9, 2025
6269d79
adjusted formatting
JonasGoseberg Dec 9, 2025
cecbc47
another formattion adjustment
JonasGoseberg Dec 9, 2025
f5964b5
small formatting adjustement
JonasGoseberg Dec 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -222,4 +222,4 @@ ARGON_TIME=2
# OPTIONAL: SCIM
# --------------------------------------------
SCIM_TRACE=false
SCIM_STANDARDS_COMPLIANCE=false
SCIM_STANDARDS_COMPLIANCE=false
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,4 @@ storage/ldap_client_tls.cert
storage/ldap_client_tls.key
/storage/framework/testing

/.phpunit.cache

#Ignore vscode AI rules
.github/instructions/codacy.instructions.md
/.phpunit.cache
14 changes: 7 additions & 7 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,19 +150,19 @@ public function render($request, Throwable $e)
// Sigh.
if ($route == 'assets.index') {
$route = 'hardware.index';
} else if ($route == 'reporttemplates.index') {
} elseif ($route == 'reporttemplates.index') {
$route = 'reports/custom';
} else if ($route == 'assetmodels.index') {
} elseif ($route == 'assetmodels.index') {
$route = 'models.index';
} else if ($route == 'predefinedkits.index') {
} elseif ($route == 'predefinedkits.index') {
$route = 'kits.index';
} else if ($route == 'assetmaintenances.index') {
} elseif ($route == 'assetmaintenances.index') {
$route = 'maintenances.index';
} else if ($route === 'licenseseats.index') {
} elseif ($route === 'licenseseats.index') {
$route = 'licenses.index';
} else if (($route === 'customfieldsets.index') || ($route === 'customfields.index')) {
} elseif (($route === 'customfieldsets.index') || ($route === 'customfields.index')) {
$route = 'fields.index';
} else if ($route === 'predefinedfilters.index') {
} elseif ($route === 'predefinedfilters.index') {
$route = 'predefined-filters.index';
}

Expand Down
73 changes: 29 additions & 44 deletions app/Http/Controllers/Api/AssetsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class AssetsController extends Controller
* @param int $assetId
* @since [v4.0]
*/
public function index(FilterRequest $request, $action = null, $upcoming_status = null):JsonResponse|array
public function index(FilterRequest $request, $action = null, $upcoming_status = null) : JsonResponse | array
{


Expand Down Expand Up @@ -135,7 +135,7 @@ public function index(FilterRequest $request, $action = null, $upcoming_status =
'created_by',

];

$all_custom_fields = CustomField::all(); //used as a 'cache' of custom fields throughout this page load

foreach ($all_custom_fields as $field) {
Expand All @@ -159,7 +159,6 @@ public function index(FilterRequest $request, $action = null, $upcoming_status =
$allowed_columns[] = $field->db_column_name();
}


$assets = Asset::select('assets.*')
->with(
'model',
Expand Down Expand Up @@ -196,7 +195,7 @@ public function index(FilterRequest $request, $action = null, $upcoming_status =
}
}

if ((!is_null($filter)) && (count($filter)) > 0) {
if ((! is_null($filter)) && (count($filter)) > 0) {
$assets->ByFilter($filter);
} elseif ($request->filled('search')) {
$assets->TextSearch($request->input('search'));
Expand All @@ -207,7 +206,7 @@ public function index(FilterRequest $request, $action = null, $upcoming_status =
* Handle due and overdue audits and checkin dates
*/
switch ($action) {
// Audit (singular) is left over from earlier legacy APIs
// Audit (singular) is left over from earlier legacy APIs
case 'audits':
switch ($upcoming_status) {
case 'due':
Expand Down Expand Up @@ -300,7 +299,7 @@ public function index(FilterRequest $request, $action = null, $upcoming_status =
break;
default:

if ((!$request->filled('status_id')) && ($settings->show_archived_in_list != '1')) {
if ((! $request->filled('status_id')) && ($settings->show_archived_in_list != '1')) {
// terrible workaround for complex-query Laravel bug in fulltext
$assets->join('status_labels AS status_alias', function ($join) {
$join->on('status_alias.id', '=', 'assets.status_id')
Expand Down Expand Up @@ -487,11 +486,9 @@ public function index(FilterRequest $request, $action = null, $upcoming_status =
* Include additional associated relationships
*/
if ($request->input('components')) {
$assets->loadMissing([
'components' => function ($query) {
$assets->loadMissing(['components' => function ($query) {
$query->orderBy('created_at', 'desc');
}
]);
}]);
}

return (new $transformer)->transformAssets($assets, $total, $request);
Expand Down Expand Up @@ -584,18 +581,11 @@ public function showBySerial(Request $request, $serial): JsonResponse | array
* @since [v4.0]
* @return \Illuminate\Http\JsonResponse
*/
public function show(Request $request, $id): JsonResponse|array
public function show(Request $request, $id): JsonResponse | array
{
if (
$asset = Asset::with('assetstatus')
->with('assignedTo')
->withTrashed()
->withCount(
'checkins as checkins_count',
'checkouts as checkouts_count',
'userRequests as user_requests_count'
)
->find($id)
if ($asset = Asset::with('assetstatus')
->with('assignedTo')->withTrashed()
->withCount('checkins as checkins_count', 'checkouts as checkouts_count', 'userRequests as user_requests_count')->find($id)
) {
$this->authorize('view', $asset);

Expand Down Expand Up @@ -636,7 +626,7 @@ public function selectlist(Request $request): array
])->with('model', 'assetstatus', 'assignedTo')
->NotArchived();

if ((Setting::getSettings()->full_multiple_companies_support=='1') && ($request->filled('companyId'))) {
if ((Setting::getSettings()->full_multiple_companies_support=='1') && ($request->filled('companyId'))) {
$assets->where('assets.company_id', $request->input('companyId'));
}

Expand Down Expand Up @@ -687,7 +677,7 @@ public function store(StoreAssetRequest $request): JsonResponse
$asset->model()->associate(AssetModel::find((int) $request->get('model_id')));

$asset->fill($request->validated());
$asset->created_by = auth()->id();
$asset->created_by = auth()->id();

/**
* this is here just legacy reasons. Api\AssetController
Expand Down Expand Up @@ -1131,6 +1121,7 @@ public function checkinByTag(Request $request, $tag = null): JsonResponse
* @since [v4.0]
*/
public function audit(Request $request, Asset $asset): JsonResponse

{
$this->authorize('audit', Asset::class);

Expand Down Expand Up @@ -1173,7 +1164,7 @@ public function audit(Request $request, Asset $asset): JsonResponse
* Update custom fields in the database.
* Validation for these fields is handled through the AssetRequest form request
* $model = AssetModel::find($request->get('model_id'));
*/
*/
if (($asset->model) && ($asset->model->fieldset)) {
$payload['custom_fields'] = [];
foreach ($asset->model->fieldset->fields as $field) {
Expand All @@ -1193,7 +1184,7 @@ public function audit(Request $request, Asset $asset): JsonResponse
$asset->{$field->db_column} = $request->input($field->db_column);
}
}
$payload['custom_fields'][$field->db_column] = $request->input($field->db_column);
$payload['custom_fields'][$field->db_column] = $request->input($field->db_column);
}

}
Expand All @@ -1204,7 +1195,7 @@ public function audit(Request $request, Asset $asset): JsonResponse

// Validate the rest of the data before we turn off the event dispatcher
if ($asset->isInvalid()) {
return response()->json(Helper::formatStandardApiResponse('error', ['asset_tag' => $asset->asset_tag], $asset->getErrors()));
return response()->json(Helper::formatStandardApiResponse('error', ['asset_tag' => $asset->asset_tag], $asset->getErrors()));
}


Expand All @@ -1225,7 +1216,7 @@ public function audit(Request $request, Asset $asset): JsonResponse
* @see \App\Models\Asset::save()
*/

$asset->unsetEventDispatcher();
$asset->unsetEventDispatcher();


/**
Expand All @@ -1241,7 +1232,7 @@ public function audit(Request $request, Asset $asset): JsonResponse


// No matching asset for the asset tag that was passed.
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/hardware/message.does_not_exist')), 200);
return response()->json(Helper::formatStandardApiResponse('error', null, trans('admin/hardware/message.does_not_exist')), 200);

}

Expand Down Expand Up @@ -1396,26 +1387,20 @@ public function getLabels(Request $request): JsonResponse
try {
$this->authorize('view', Asset::class);

// Validate that asset tags were provided in the request
// Validate that asset tags were provided in the request
if (!$request->filled('asset_tags')) {
return response()->json(Helper::formatStandardApiResponse(
'error',
null,
trans('admin/hardware/message.no_assets_selected')
), 400);
return response()->json(Helper::formatStandardApiResponse('error', null,
trans('admin/hardware/message.no_assets_selected')), 400);
}

// Convert asset tags from request into collection and fetch matching assets
// Convert asset tags from request into collection and fetch matching assets
$asset_tags = collect($request->input('asset_tags'));
$assets = Asset::whereIn('asset_tag', $asset_tags)->get();

// Return error if no assets were found for the provided tags
// Return error if no assets were found for the provided tags
if ($assets->isEmpty()) {
return response()->json(Helper::formatStandardApiResponse(
'error',
null,
trans('admin/hardware/message.does_not_exist')
), 404);
return response()->json(Helper::formatStandardApiResponse('error', null,
trans('admin/hardware/message.does_not_exist')), 404);
}

try {
Expand All @@ -1435,9 +1420,9 @@ public function getLabels(Request $request): JsonResponse
// Configure label with assets and settings
// bulkedit=false and count=0 are default values for label generation
$label = $label->with('assets', $assets)
->with('settings', $settings)
->with('bulkedit', false)
->with('count', 0);
->with('settings', $settings)
->with('bulkedit', false)
->with('count', 0);

// Generate PDF using callback function
// The callback captures the PDF content in $pdf_content variable
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/Api/GroupsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function show($id) : array
* @param \Illuminate\Http\Request $request
* @param int $id
*/
public function update(Request $request, $id): JsonResponse
public function update(Request $request, $id) : JsonResponse
{
$this->authorize('superadmin');
$group = Group::findOrFail($id);
Expand All @@ -138,7 +138,7 @@ public function update(Request $request, $id): JsonResponse
* @since [v4.0]
* @param int $id
*/
public function destroy($id): JsonResponse
public function destroy($id) : JsonResponse
{
$this->authorize('superadmin');
$group = Group::findOrFail($id);
Expand Down
Loading
Loading