A free open source IT asset/license management system
add validation for label import, fix footer on label edit blade
Godfrey M37998287fef9
diff --git a/app/Console/Commands/LdapTroubleshooter.php b/app/Console/Commands/LdapTroubleshooter.phpindex 6921e46499..eb28b2a0b7 100644--- a/app/Console/Commands/LdapTroubleshooter.php+++ b/app/Console/Commands/LdapTroubleshooter.php@@ -27,7 +27,7 @@ function ip_in_range($ip, $range)$wildcard_decimal = pow(2, (32 - $netmask)) - 1;$netmask_decimal = ~$wildcard_decimal;- return ($ip_decimal & $netmask_decimal) == ($range_decimal & $netmask_decimal);+ return ($ip_decimal & $netmask_decimal) == ($range_decimal & $netmask_decimal);}// NOTE - this function was shamelessly stolen from this gist: https://gist.github.com/tott/7684443diff --git a/app/Console/Commands/RestoreFromBackup.php b/app/Console/Commands/RestoreFromBackup.phpindex f9d96b7f05..e00bc83dad 100644--- a/app/Console/Commands/RestoreFromBackup.php+++ b/app/Console/Commands/RestoreFromBackup.php@@ -456,10 +456,10 @@ class RestoreFromBackup extends Commandif (! file_exists($mysql_binary)) {return $this->error("mysql tool at: '$mysql_binary' does not exist, cannot restore. Please edit DB_DUMP_PATH in your .env to point to a directory that contains the mysqldump and mysql binary");}- $proc_results = proc_open("$mysql_binary -h " .- escapeshellarg(config('database.connections.mysql.host')) .- ' -u ' . escapeshellarg(config('database.connections.mysql.username')) . ' ' .- ' -P ' . escapeshellarg(config('database.connections.mysql.port')) . ' ' .+ $proc_results = proc_open("$mysql_binary -h ".+ escapeshellarg(config('database.connections.mysql.host')).+ ' -u '.escapeshellarg(config('database.connections.mysql.username')).' '.+ ' -P '.escapeshellarg(config('database.connections.mysql.port')).' '.escapeshellarg(config('database.connections.mysql.database')), // yanked -p since we pass via ENV[0 => ['pipe', 'r'], 1 => ['pipe', 'w'], 2 => ['pipe', 'w']],$pipes,diff --git a/app/Http/Controllers/Api/LabelsController.php b/app/Http/Controllers/Api/LabelsController.phpindex 8db46a8e99..d725213046 100644--- a/app/Http/Controllers/Api/LabelsController.php+++ b/app/Http/Controllers/Api/LabelsController.php@@ -5,12 +5,12 @@ namespace App\Http\Controllers\Api;use App\Helpers\Helper;use App\Http\Controllers\Controller;use App\Http\Transformers\LabelsTransformer;+use App\Models\Labels\CustomLabels\PreviewLabel;use App\Models\Labels\CustomUserLabel;use App\Models\Labels\Label;use Illuminate\Http\JsonResponse;use Illuminate\Http\Request;use Illuminate\Support\ItemNotFoundException;-use App\Models\Labels\CustomLabels\PreviewLabel;class LabelsController extends Controller{@@ -24,7 +24,7 @@ class LabelsController extends Controller$this->authorize('view', Label::class);$baseLabels = Label::find()- ->reject(fn(Label $label) => $label instanceof PreviewLabel)+ ->reject(fn (Label $label) => $label instanceof PreviewLabel)->map(function (Label $label) {return ['source' => 'base',diff --git a/app/Http/Controllers/Api/SettingsController.php b/app/Http/Controllers/Api/SettingsController.phpindex 63ed0ef578..043b072192 100644--- a/app/Http/Controllers/Api/SettingsController.php+++ b/app/Http/Controllers/Api/SettingsController.php@@ -165,6 +165,7 @@ class SettingsController extends Controllerif (config('mail.reply_to.address') == '') {Log::debug('MAIL_REPLYTO_ADDR not set in env. Skipping mail test.');+return response()->json(['message' => trans('admin/settings/general.mail_test_no_email')], 403);}diff --git a/app/Http/Controllers/LabelsController.php b/app/Http/Controllers/LabelsController.phpindex 8ff7da9339..9b7b154cc7 100755--- a/app/Http/Controllers/LabelsController.php+++ b/app/Http/Controllers/LabelsController.php@@ -7,19 +7,17 @@ use App\Models\AssetModel;use App\Models\Category;use App\Models\Company;use App\Models\CustomField;-use App\Models\Labels\CustomLabels\CustomLabel;use App\Models\Labels\CustomLabels\PreviewLabel;use App\Models\Labels\CustomUserLabel;-use App\Models\Labels\CustomLabels\CustomSheetLabel;use App\Models\Labels\DefaultLabel;use App\Models\Labels\Label;use App\Models\Location;use App\Models\Manufacturer;use App\Models\Setting;-use Illuminate\Http\Request;use App\Models\Supplier;use App\Models\User;use App\View\Label as LabelView;+use Illuminate\Http\Request;use Illuminate\Validation\ValidationException;class LabelsController extends Controller@@ -39,13 +37,13 @@ class LabelsController extends Controller$customLabel = CustomUserLabel::find($id);if (!$customLabel) {- $template = new DefaultLabel();+ $template = new DefaultLabel;} else {$baseLabel = CustomUserLabel::makeBaseLabel(data_get($customLabel->config_snapshot, 'template', $customLabel->base_label));- $template = new PreviewLabel();+ $template = new PreviewLabel;if ($baseLabel) {$template->seedFromTemplate($baseLabel);@@ -57,12 +55,11 @@ class LabelsController extends Controller} else {$template = $labelName === 'DefaultLabel'- ? new DefaultLabel()+ ? new DefaultLabel: Label::find($labelName);}-$exampleAsset = new Asset;$exampleAsset->id = 999999;@@ -124,7 +121,7 @@ class LabelsController extends Controller}}- return (new LabelView())+ return (new LabelView)->with('assets', collect([$exampleAsset]))->with('settings', $settings)->with('template', $template)@@ -186,8 +183,7 @@ class LabelsController extends Controllerreturn redirect()->back()->with('error', trans('admin/labels/labels.base_label_missing'));}-- $baseWorkingLabel = new PreviewLabel();+ $baseWorkingLabel = new PreviewLabel;$baseWorkingLabel->seedFromTemplate($baseLabel);$baseEditorConfig = $baseWorkingLabel->toEditorConfig();@@ -203,7 +199,7 @@ class LabelsController extends Controller$mergedConfig = array_replace_recursive($baseConfig, $submittedConfig);- $workingLabel = new PreviewLabel();+ $workingLabel = new PreviewLabel;$workingLabel->seedFromTemplate($baseLabel);$workingLabel->applyEditorConfig($mergedConfig);@@ -239,6 +235,7 @@ class LabelsController extends Controller->route('settings.labels.index')->with('success', $label->name . ' updated successfully.');}+public function store(Request $request){@@ -270,6 +267,7 @@ class LabelsController extends Controllerif (is_numeric($value)) {return (float)$value;}+return $value;})->toArray();};@@ -286,7 +284,7 @@ class LabelsController extends Controller}// Loading both base and working label in the preview to ensure millimeter-based comparisons for overrides.- $baseWorkingLabel = new PreviewLabel();+ $baseWorkingLabel = new PreviewLabel;$baseWorkingLabel->seedFromTemplate($baseLabel);$baseConfig = $baseWorkingLabel->getEditorConfigSections();@@ -300,7 +298,7 @@ class LabelsController extends Controller$mergedConfig = array_replace_recursive($baseConfig, $submittedConfig);- $workingLabel = new PreviewLabel();+ $workingLabel = new PreviewLabel;$workingLabel->seedFromTemplate($baseLabel);$workingLabel->applyEditorConfig($mergedConfig);@@ -334,7 +332,7 @@ class LabelsController extends Controller$customLabelId = $request->get('custom_label_id');if ($customLabelId) {- //creating a custom label from another custom label+ // creating a custom label from another custom label$customLabel = CustomUserLabel::findOrFail($customLabelId);$config = $customLabel->config_snapshot;@@ -362,13 +360,13 @@ class LabelsController extends Controllertry {$template = $selectedLabel? Label::find(str_replace('/', '\\', $selectedLabel))- : new DefaultLabel();+ : new DefaultLabel;} catch (\Throwable $e) {- $template = new DefaultLabel();- $selectedLabel = "DefaultLabel";+ $template = new DefaultLabel;+ $selectedLabel = 'DefaultLabel';}- $label = (new PreviewLabel())->seedFromTemplate($template);+ $label = (new PreviewLabel)->seedFromTemplate($template);$config = $importedConfig ?: $label->toEditorConfig();return view('settings.label-edit', [@@ -403,7 +401,7 @@ class LabelsController extends Controller$labelName = str_replace('/', '\\', $labelName);$baseTemplate = $labelName === 'DefaultLabel'- ? new DefaultLabel()+ ? new DefaultLabel: Label::find($labelName);$editorConfig = [@@ -414,7 +412,7 @@ class LabelsController extends Controller'supports' => $request->input('supports', []),];- $template = new \App\Models\Labels\CustomLabels\PreviewLabel();+ $template = new PreviewLabel;if (method_exists($template, 'seedFromTemplate')) {$template->seedFromTemplate($baseTemplate);@@ -516,31 +514,210 @@ class LabelsController extends Controller->with('count', 0);}+public function import(Request $request){- $validated = $request->validate([- 'config_snapshot' => ['required', 'json'],+ $request->validate([+ 'import_method' => ['required', 'in:json,text'],+ 'config_file' => ['required_if:import_method,json', 'file', 'mimes:json,txt'],+ 'config_snapshot' => ['required_if:import_method,text', 'nullable', 'string'],]);- $config = json_decode($validated['config_snapshot'], true);+ $rawJson = $request->input('import_method') === 'json'+ ? file_get_contents($request->file('config_file')->getRealPath())+ : $request->input('config_snapshot');- if (!is_array($config)) {- throw ValidationException::withMessages([- 'config_snapshot' => 'The imported label config must be a JSON object.',- ]);+ $config = json_decode($rawJson, true);++ if (json_last_error() !== JSON_ERROR_NONE || !is_array($config)) {+ return back()+ ->withErrors(['config_snapshot' => 'The imported label config must be valid JSON.'])+ ->withInput();}- foreach (['template', 'type', 'name'] as $requiredKey) {- if (!array_key_exists($requiredKey, $config)) {- throw ValidationException::withMessages([- 'config_snapshot' => "The imported label config is missing [{$requiredKey}].",- ]);- }+ $configValidator = validator(+ $config,+ [+ 'unit' => ['required', 'string', 'in:mm'],+ 'template' => ['required', 'string'],+ 'type' => ['required', 'string', 'in:sheet'],+ 'name' => ['required', 'string'],++ /*+ |--------------------------------------------------------------------------+ | Page+ |--------------------------------------------------------------------------+ */+ 'page' => ['required', 'array'],+ 'page.width' => ['required', 'numeric'],+ 'page.height' => ['required', 'numeric'],+ 'page.margin_top' => ['required', 'numeric'],+ 'page.margin_right' => ['required', 'numeric'],+ 'page.margin_bottom' => ['required', 'numeric'],+ 'page.margin_left' => ['required', 'numeric'],++ /*+ |--------------------------------------------------------------------------+ | Grid+ |--------------------------------------------------------------------------+ */+ 'grid' => ['required', 'array'],+ 'grid.columns' => ['required', 'integer'],+ 'grid.rows' => ['required', 'integer'],+ 'grid.column_spacing' => ['required', 'numeric'],+ 'grid.row_spacing' => ['required', 'numeric'],++ /*+ |--------------------------------------------------------------------------+ | Printable Area+ |--------------------------------------------------------------------------+ */+ 'printable_area' => ['required', 'array'],+ 'printable_area.x1' => ['required', 'numeric'],+ 'printable_area.y1' => ['required', 'numeric'],+ 'printable_area.x2' => ['required', 'numeric'],+ 'printable_area.y2' => ['required', 'numeric'],+ 'printable_area.width' => ['required', 'numeric'],+ 'printable_area.height' => ['required', 'numeric'],++ /*+ |--------------------------------------------------------------------------+ | Label+ |--------------------------------------------------------------------------+ */+ 'label' => ['required', 'array'],+ 'label.width' => ['required', 'numeric'],+ 'label.height' => ['required', 'numeric'],+ 'label.border' => ['required', 'numeric'],+ 'label.padding_top' => ['required', 'numeric'],+ 'label.padding_right' => ['required', 'numeric'],+ 'label.padding_bottom' => ['required', 'numeric'],+ 'label.padding_left' => ['required', 'numeric'],++ /*+ |--------------------------------------------------------------------------+ | Content+ |--------------------------------------------------------------------------+ */+ 'content' => ['required', 'array'],++ 'content.barcode_size' => ['required', 'numeric'],+ 'content.barcode_margin' => ['required', 'numeric'],++ 'content.barcode2D_h_align' => ['required', 'string', 'in:L,C,R'],+ 'content.barcode2D_v_align' => ['required', 'string', 'in:T,C,B'],++ 'content.tag_alignment' => ['required', 'string', 'in:L,C,R'],++ 'content.barcode_2d_size' => ['required', 'numeric'],++ 'content.logo_max_width' => ['required', 'numeric'],+ 'content.logo_margin' => ['required', 'numeric'],++ 'content.logo_h_align' => ['required', 'string', 'in:L,C,R'],+ 'content.logo_v_align' => ['required', 'string', 'in:T,C,B'],++ 'content.tag_font_size' => ['required', 'numeric'],+ 'content.tag_offset_x' => ['required', 'numeric'],+ 'content.tag_offset_y' => ['required', 'numeric'],++ 'content.title_font_size' => ['required', 'numeric'],+ 'content.title_margin' => ['required', 'numeric'],+ 'content.title_offset_x' => ['required', 'numeric'],++ 'content.field_label_font_size' => ['required', 'numeric'],+ 'content.field_label_margin' => ['required', 'numeric'],++ 'content.field_value_font_size' => ['required', 'numeric'],+ 'content.field_value_margin' => ['required', 'numeric'],++ 'content.text_area_width' => ['nullable', 'numeric'],+ 'content.text_area_height' => ['nullable', 'numeric'],++ /*+ |--------------------------------------------------------------------------+ | Supports+ |--------------------------------------------------------------------------+ */+ 'supports' => ['required', 'array'],+ 'supports.asset_tag' => ['required', 'boolean'],+ 'supports.barcode_1d' => ['required', 'boolean'],+ 'supports.barcode_2d' => ['required', 'boolean'],+ 'supports.fields' => ['required', 'integer'],+ 'supports.logo' => ['required', 'boolean'],+ 'supports.title' => ['required', 'boolean'],+ ],+ [],+ [+ 'page.width' => 'page width',+ 'page.height' => 'page height',+ 'page.margin_top' => 'page top margin',+ 'page.margin_right' => 'page right margin',+ 'page.margin_bottom' => 'page bottom margin',+ 'page.margin_left' => 'page left margin',++ 'grid.columns' => 'grid columns',+ 'grid.rows' => 'grid rows',+ 'grid.column_spacing' => 'grid column spacing',+ 'grid.row_spacing' => 'grid row spacing',++ 'printable_area.x1' => 'printable area x1',+ 'printable_area.y1' => 'printable area y1',+ 'printable_area.x2' => 'printable area x2',+ 'printable_area.y2' => 'printable area y2',+ 'printable_area.width' => 'printable area width',+ 'printable_area.height' => 'printable area height',++ 'label.width' => 'label width',+ 'label.height' => 'label height',+ 'label.border' => 'label border',+ 'label.padding_top' => 'label top padding',+ 'label.padding_right' => 'label right padding',+ 'label.padding_bottom' => 'label bottom padding',+ 'label.padding_left' => 'label left padding',++ 'content.barcode_size' => 'barcode size',+ 'content.barcode_margin' => 'barcode margin',+ 'content.barcode2D_h_align' => '2D barcode horizontal alignment',+ 'content.barcode2D_v_align' => '2D barcode vertical alignment',+ 'content.tag_alignment' => 'tag alignment',+ 'content.barcode_2d_size' => '2D barcode size',+ 'content.logo_max_width' => 'logo max width',+ 'content.logo_margin' => 'logo margin',+ 'content.logo_h_align' => 'logo horizontal alignment',+ 'content.logo_v_align' => 'logo vertical alignment',+ 'content.tag_font_size' => 'tag font size',+ 'content.tag_offset_x' => 'tag horizontal offset',+ 'content.tag_offset_y' => 'tag vertical offset',+ 'content.title_font_size' => 'title font size',+ 'content.title_margin' => 'title margin',+ 'content.title_offset_x' => 'title horizontal offset',+ 'content.field_label_font_size' => 'field label font size',+ 'content.field_label_margin' => 'field label margin',+ 'content.field_value_font_size' => 'field value font size',+ 'content.field_value_margin' => 'field value margin',+ 'content.text_area_width' => 'text area width',+ 'content.text_area_height' => 'text area height',++ 'supports.asset_tag' => 'supports asset tag',+ 'supports.barcode_1d' => 'supports 1D barcode',+ 'supports.barcode_2d' => 'supports 2D barcode',+ 'supports.fields' => 'supports fields',+ 'supports.logo' => 'supports logo',+ 'supports.title' => 'supports title',+ ]+ );++ if ($configValidator->fails()) {+ return back()+ ->withErrors([+ 'config_snapshot' => $configValidator->errors()->all(),+ ])+ ->withInput();}return redirect()->route('settings.labels.create')->with('imported_label_config', $config);}-}diff --git a/app/Http/Controllers/SettingsController.php b/app/Http/Controllers/SettingsController.phpindex 15195f6e86..276719942e 100644--- a/app/Http/Controllers/SettingsController.php+++ b/app/Http/Controllers/SettingsController.php@@ -529,7 +529,6 @@ class SettingsController extends Controller->with('customFields', CustomField::where('field_encrypted', '=', 0)->get());}-/*** Saves settings from form.*diff --git a/app/Http/Controllers/StorageProxyController.php b/app/Http/Controllers/StorageProxyController.phpindex efed5e5c51..d145e3ae2c 100644--- a/app/Http/Controllers/StorageProxyController.php+++ b/app/Http/Controllers/StorageProxyController.php@@ -23,7 +23,7 @@ class StorageProxyController extends Controller// but Flysystem also prepends it internally on every operation.// Strip it here to avoid double-prefixing.$root = trim(config('filesystems.disks.public.root', ''), '/');- if ($root !== '' && str_starts_with($path, $root . '/')) {+ if ($root !== '' && str_starts_with($path, $root.'/')) {$path = substr($path, strlen($root) + 1);}@@ -33,12 +33,12 @@ class StorageProxyController extends Controller$mimeType = $disk->mimeType($path) ?: 'application/octet-stream';$lastModified = $disk->lastModified($path);- $etag = md5($path . $lastModified);+ $etag = md5($path.$lastModified);$size = $disk->size($path);if ($this->isNotModified($etag, $lastModified)) {return response('', 304)- ->header('ETag', '"' . $etag . '"')+ ->header('ETag', '"'.$etag.'"')->header('Cache-Control', 'public, max-age=86400');}@@ -51,8 +51,8 @@ class StorageProxyController extends Controller}, 200, ['Content-Type' => $mimeType,'Content-Length' => $size,- 'ETag' => '"' . $etag . '"',- 'Last-Modified' => gmdate('D, d M Y H:i:s', $lastModified) . ' GMT',+ 'ETag' => '"'.$etag.'"',+ 'Last-Modified' => gmdate('D, d M Y H:i:s', $lastModified).' GMT','Cache-Control' => 'public, max-age=86400',]);}@@ -60,7 +60,7 @@ class StorageProxyController extends Controllerprivate function isNotModified(string $etag, int $lastModified): bool{$requestEtag = request()->header('If-None-Match');- if ($requestEtag && $requestEtag === '"' . $etag . '"') {+ if ($requestEtag && $requestEtag === '"'.$etag.'"') {return true;}diff --git a/app/Http/Requests/StoreLabelSettings.php b/app/Http/Requests/StoreLabelSettings.phpindex 29cc38643f..77db4ec70a 100644--- a/app/Http/Requests/StoreLabelSettings.php+++ b/app/Http/Requests/StoreLabelSettings.php@@ -2,12 +2,12 @@namespace App\Http\Requests;+use App\Models\Labels\CustomUserLabel;use App\Models\Labels\Label;use Illuminate\Contracts\Validation\ValidationRule;use Illuminate\Foundation\Http\FormRequest;use Illuminate\Support\Facades\Gate;use Illuminate\Validation\Rule;-use App\Models\Labels\CustomUserLabel;class StoreLabelSettings extends FormRequest{@@ -32,7 +32,7 @@ class StoreLabelSettings extends FormRequest$customNames = CustomUserLabel::query()->pluck('id')- ->map(fn($id) => 'custom:' . $id)+ ->map(fn ($id) => 'custom:'.$id)->values()->toArray();diff --git a/app/Http/Transformers/LabelsTransformer.php b/app/Http/Transformers/LabelsTransformer.phpindex df939d70db..10efa266bd 100644--- a/app/Http/Transformers/LabelsTransformer.php+++ b/app/Http/Transformers/LabelsTransformer.php@@ -2,11 +2,11 @@namespace App\Http\Transformers;+use App\Models\Labels\CustomUserLabel;use App\Models\Labels\Label;use App\Models\Labels\RectangleSheet;use App\Models\Labels\Sheet;use Illuminate\Support\Collection;-use App\Models\Labels\CustomUserLabel;class LabelsTransformer{@@ -93,8 +93,8 @@ class LabelsTransformer'unit' => 'mm',- 'width' => number_format((float)data_get($snapshot, 'label.width', 0), 2),- 'height' => number_format((float)data_get($snapshot, 'label.height', 0), 2),+ 'width' => number_format((float) data_get($snapshot, 'label.width', 0), 2),+ 'height' => number_format((float) data_get($snapshot, 'label.height', 0), 2),'margin_top' => data_get($snapshot, 'label.margin_top'),'margin_bottom' => data_get($snapshot, 'label.margin_bottom'),diff --git a/app/Listeners/CheckoutableListener.php b/app/Listeners/CheckoutableListener.phpindex 6a9a0fc1ff..345d337bea 100644--- a/app/Listeners/CheckoutableListener.php+++ b/app/Listeners/CheckoutableListener.php@@ -40,6 +40,7 @@ use Illuminate\Support\Facades\Mail;use Illuminate\Support\Facades\Notification;use Illuminate\Support\Str;use Osama\LaravelTeamsNotification\TeamsNotification;+class CheckoutableListener{private array $skipNotificationsFor = [diff --git a/app/Listeners/CheckoutablesCheckedOutInBulkListener.php b/app/Listeners/CheckoutablesCheckedOutInBulkListener.phpindex 3f6a367c97..b621974271 100644--- a/app/Listeners/CheckoutablesCheckedOutInBulkListener.php+++ b/app/Listeners/CheckoutablesCheckedOutInBulkListener.php@@ -9,7 +9,6 @@ use App\Models\Location;use App\Models\Setting;use App\Models\User;use Exception;-use Illuminate\Database\Eloquent\Model;use Illuminate\Support\Collection;use Illuminate\Support\Facades\Log;use Illuminate\Support\Facades\Mail;diff --git a/app/Models/Labels/CustomLabels/CustomLabel.php b/app/Models/Labels/CustomLabels/CustomLabel.phpindex 3cf954f7a7..839f884040 100644--- a/app/Models/Labels/CustomLabels/CustomLabel.php+++ b/app/Models/Labels/CustomLabels/CustomLabel.php@@ -2,27 +2,34 @@namespace App\Models\Labels\CustomLabels;-use App\Models\Labels\Label;use App\Models\Labels\RectangleSheet;abstract class CustomLabel extends RectangleSheet{protected array $editorConfig = [];+protected ?float $pageWidth = null;+protected ?float $pageHeight = null;protected ?float $pageMarginTop = null;+protected ?float $pageMarginRight = null;+protected ?float $pageMarginBottom = null;+protected ?float $pageMarginLeft = null;protected ?float $labelWidth = null;+protected ?float $labelHeight = null;protected ?float $columnSpacing = null;+protected ?float $rowSpacing = null;protected ?int $gridColumns = null;+protected ?int $gridRows = null;public function applyEditorConfig(array $config): static@@ -55,4 +62,4 @@ abstract class CustomLabel extends RectangleSheet$this->columnSpacing = $grid['column_spacing'] ?? $this->columnSpacing;$this->rowSpacing = $grid['row_spacing'] ?? $this->rowSpacing;}-}\ No newline at end of file+}diff --git a/app/Models/Labels/CustomLabels/CustomSheetLabel.php b/app/Models/Labels/CustomLabels/CustomSheetLabel.phpindex 89bc5e15f8..708b647d5c 100644--- a/app/Models/Labels/CustomLabels/CustomSheetLabel.php+++ b/app/Models/Labels/CustomLabels/CustomSheetLabel.php@@ -3,69 +3,105 @@namespace App\Models\Labels\CustomLabels;use App\Helpers\Helper;-use App\Models\Labels\RectangleSheet;abstract class CustomSheetLabel extends CustomLabel{protected string $unit = 'mm';protected ?float $pageWidth = 210.0;+protected ?float $pageHeight = 297.0;protected ?float $pageMarginTop = 0.0;+protected ?float $pageMarginRight = 0.0;+protected ?float $pageMarginBottom = 0.0;+protected ?float $pageMarginLeft = 0.0;protected int $rows = 9;+protected int $columns = 3;protected ?float $labelWidth = 50.0;+protected ?float $labelHeight = 25.0;protected float $labelRowSpacing = 0.0;+protected float $labelColumnSpacing = 0.0;protected float $labelMarginTop = 0.0;+protected float $labelMarginRight = 0.0;+protected float $labelMarginBottom = 0.0;+protected float $labelMarginLeft = 0.0;protected bool $supportTitle = true;+protected int $supportFields = 4;+protected bool $support1DBarcode = true;+protected bool $support2DBarcode = false;+protected bool $supportLogo = false;+protected bool $supportAssetTag = true;protected float $barcodeSize = 3;+protected float $barcode2DSize = 20;+protected float $barcodeMargin = .025;+protected float $barcode2Margin = 0.075;+protected float $logoMaxWidth = 12.0;+protected float $logoMargin = 2.0;+protected string $logoHAlign = 'L';+protected string $logoVAlign = 'T';+protected float $tagSize = 6.0;+protected float $titleSize = 8.0;+protected float $labelSize = 6.0;- protected float $fieldSize = 7.0;+ protected float $fieldSize = 7.0;protected float $titleMargin = 2.0;+protected float $titleOffsetX = 0.0;+protected float $labelMargin = 1.5;+protected float $fieldMargin = 2.0;protected string $tagAlignment = 'L';+protected string $barcode2DHAlign = 'L';+protected string $barcode2DVAlign = 'T';+protected string $tagHAlign = 'R';+protected string $tagVAlign = 'B';+protected string $tagPositionMode = 'free';+protected ?float $textAreaWidth = null;+protected ?float $textAreaHeight = null;+protected float $tagOffsetX = 0.0;+protected float $tagOffsetY = 0.0;public function getTagOffsetX(): float@@ -77,6 +113,7 @@ abstract class CustomSheetLabel extends CustomLabel{return $this->tagOffsetY;}+public function getUnit(){return $this->unit;@@ -271,6 +308,7 @@ abstract class CustomSheetLabel extends CustomLabel{return $this->fieldMargin;}+public function getLabelBorder(){return 0;@@ -355,7 +393,7 @@ abstract class CustomSheetLabel extends CustomLabel}return $sourceUnit === 'in' && is_numeric($value)- ? (float)$value * 25.4+ ? (float) $value * 25.4: $value;};@@ -396,11 +434,11 @@ abstract class CustomSheetLabel extends CustomLabel|--------------------------------------------------------------------------*/if (method_exists($template, 'getRows')) {- $this->rows = (int)$template->getRows();+ $this->rows = (int) $template->getRows();}if (method_exists($template, 'getColumns')) {- $this->columns = (int)$template->getColumns();+ $this->columns = (int) $template->getColumns();}/*@@ -458,7 +496,7 @@ abstract class CustomSheetLabel extends CustomLabel| Special legacy fallbacks|--------------------------------------------------------------------------*/- if (method_exists($template, 'getLogoSize') && !method_exists($template, 'getLogoMaxWidth')) {+ if (method_exists($template, 'getLogoSize') && ! method_exists($template, 'getLogoMaxWidth')) {$logoSize = $template->getLogoSize();$this->logoMaxWidth = isset($logoSize[0])? $convert($logoSize[0])@@ -468,19 +506,19 @@ abstract class CustomSheetLabel extends CustomLabelif (method_exists($template, 'getTextSize')) {$textSize = $convert($template->getTextSize());- if (!method_exists($template, 'getTagSize')) {+ if (! method_exists($template, 'getTagSize')) {$this->tagSize = $textSize;}- if (!method_exists($template, 'getTitleSize')) {+ if (! method_exists($template, 'getTitleSize')) {$this->titleSize = $textSize;}- if (!method_exists($template, 'getLabelSize')) {+ if (! method_exists($template, 'getLabelSize')) {$this->labelSize = $textSize;}- if (!method_exists($template, 'getFieldSize')) {+ if (! method_exists($template, 'getFieldSize')) {$this->fieldSize = $textSize;}}@@ -488,15 +526,15 @@ abstract class CustomSheetLabel extends CustomLabelif (method_exists($template, 'getTextMargin')) {$textMargin = $convert($template->getTextMargin());- if (!method_exists($template, 'getTitleMargin')) {+ if (! method_exists($template, 'getTitleMargin')) {$this->titleMargin = $textMargin;}- if (!method_exists($template, 'getLabelMargin')) {+ if (! method_exists($template, 'getLabelMargin')) {$this->labelMargin = $textMargin;}- if (!method_exists($template, 'getFieldMargin')) {+ if (! method_exists($template, 'getFieldMargin')) {$this->fieldMargin = $textMargin;}}@@ -545,7 +583,7 @@ abstract class CustomSheetLabel extends CustomLabelforeach ($stringContentMap as $key => $property) {if (array_key_exists($key, $content)) {- $this->{$property} = (string)$content[$key];+ $this->{$property} = (string) $content[$key];}}@@ -568,57 +606,58 @@ abstract class CustomSheetLabel extends CustomLabel$supports = $config['supports'] ?? [];$content = $config['content'] ?? [];- $this->pageWidth = isset($page['width']) ? (float)$page['width'] : $this->pageWidth;- $this->pageHeight = isset($page['height']) ? (float)$page['height'] : $this->pageHeight;-- $this->pageMarginTop = isset($page['margin_top']) ? (float)$page['margin_top'] : $this->pageMarginTop;- $this->pageMarginRight = isset($page['margin_right']) ? (float)$page['margin_right'] : $this->pageMarginRight;- $this->pageMarginBottom = isset($page['margin_bottom']) ? (float)$page['margin_bottom'] : $this->pageMarginBottom;- $this->pageMarginLeft = isset($page['margin_left']) ? (float)$page['margin_left'] : $this->pageMarginLeft;-- $this->rows = isset($grid['rows']) ? (int)$grid['rows'] : $this->rows;- $this->columns = isset($grid['columns']) ? (int)$grid['columns'] : $this->columns;- $this->labelRowSpacing = isset($grid['row_spacing']) ? (float)$grid['row_spacing'] : $this->labelRowSpacing;- $this->labelColumnSpacing = isset($grid['column_spacing']) ? (float)$grid['column_spacing'] : $this->labelColumnSpacing;-- $this->labelWidth = isset($label['width']) ? (float)$label['width'] : $this->labelWidth;- $this->labelHeight = isset($label['height']) ? (float)$label['height'] : $this->labelHeight;-- $this->labelMarginTop = isset($label['padding_top']) ? (float)$label['padding_top'] : $this->labelMarginTop;- $this->labelMarginRight = isset($label['padding_right']) ? (float)$label['padding_right'] : $this->labelMarginRight;- $this->labelMarginBottom = isset($label['padding_bottom']) ? (float)$label['padding_bottom'] : $this->labelMarginBottom;- $this->labelMarginLeft = isset($label['padding_left']) ? (float)$label['padding_left'] : $this->labelMarginLeft;-- $this->supportFields = isset($supports['fields']) ? (int)$supports['fields'] : $this->supportFields;- $this->supportTitle = (bool)($supports['title'] ?? false);- $this->support1DBarcode = (bool)($supports['barcode_1d'] ?? false);- $this->support2DBarcode = (bool)($supports['barcode_2d'] ?? false);- $this->supportLogo = (bool)($supports['logo'] ?? false);- $this->supportAssetTag = (bool)($supports['asset_tag'] ?? false);-- $this->barcodeSize = isset($content['barcode_size']) ? (float)$content['barcode_size'] : $this->barcodeSize;- $this->barcodeMargin = isset($content['barcode_margin']) ? (float)$content['barcode_margin'] : $this->barcodeMargin;- $this->barcode2DSize = isset($content['barcode_2d_size']) ? (float)$content['barcode_2d_size'] : $this->barcode2DSize;- $this->logoMaxWidth = isset($content['logo_max_width']) ? (float)$content['logo_max_width'] : $this->logoMaxWidth;- $this->logoMargin = isset($content['logo_margin']) ? (float)$content['logo_margin'] : $this->logoMargin;- $this->logoHAlign = isset($content['logo_h_align']) ? (string)$content['logo_h_align'] : $this->logoHAlign;- $this->logoVAlign = isset($content['logo_v_align']) ? (string)$content['logo_v_align'] : $this->logoVAlign;-- $this->tagSize = isset($content['tag_font_size']) ? (float)$content['tag_font_size'] : $this->tagSize;- $this->tagOffsetX = isset($content['tag_offset_x']) ? (float)$content['tag_offset_x'] : $this->tagOffsetX;- $this->tagOffsetY = isset($content['tag_offset_y']) ? (float)$content['tag_offset_y'] : $this->tagOffsetY;- $this->tagAlignment = isset($content['tag_alignment']) ? (string)$content['tag_alignment'] : $this->tagAlignment;- $this->titleSize = isset($content['title_font_size']) ? (float)$content['title_font_size'] : $this->titleSize;- $this->labelSize = isset($content['field_label_font_size']) ? (float)$content['field_label_font_size'] : $this->labelSize;- $this->fieldSize = isset($content['field_value_font_size']) ? (float)$content['field_value_font_size'] : $this->fieldSize;- $this->textAreaWidth = isset($content['text_area_width']) && $content['text_area_width'] !== '' ? (float)$content['text_area_width'] : $this->textAreaWidth;- $this->textAreaHeight = isset($content['text_area_height']) && $content['text_area_height'] !== '' ? (float)$content['text_area_height'] : $this->textAreaHeight;-- $this->titleMargin = isset($content['title_margin']) ? (float)$content['title_margin'] : $this->titleMargin;- $this->titleOffsetX = isset($content['title_offset_x']) ? (float)$content['title_offset_x'] : $this->titleOffsetX;- $this->labelMargin = isset($content['field_label_margin']) ? (float)$content['field_label_margin'] : $this->labelMargin;- $this->fieldMargin = isset($content['field_value_margin']) ? (float)$content['field_value_margin'] : $this->fieldMargin;+ $this->pageWidth = isset($page['width']) ? (float) $page['width'] : $this->pageWidth;+ $this->pageHeight = isset($page['height']) ? (float) $page['height'] : $this->pageHeight;++ $this->pageMarginTop = isset($page['margin_top']) ? (float) $page['margin_top'] : $this->pageMarginTop;+ $this->pageMarginRight = isset($page['margin_right']) ? (float) $page['margin_right'] : $this->pageMarginRight;+ $this->pageMarginBottom = isset($page['margin_bottom']) ? (float) $page['margin_bottom'] : $this->pageMarginBottom;+ $this->pageMarginLeft = isset($page['margin_left']) ? (float) $page['margin_left'] : $this->pageMarginLeft;++ $this->rows = isset($grid['rows']) ? (int) $grid['rows'] : $this->rows;+ $this->columns = isset($grid['columns']) ? (int) $grid['columns'] : $this->columns;+ $this->labelRowSpacing = isset($grid['row_spacing']) ? (float) $grid['row_spacing'] : $this->labelRowSpacing;+ $this->labelColumnSpacing = isset($grid['column_spacing']) ? (float) $grid['column_spacing'] : $this->labelColumnSpacing;++ $this->labelWidth = isset($label['width']) ? (float) $label['width'] : $this->labelWidth;+ $this->labelHeight = isset($label['height']) ? (float) $label['height'] : $this->labelHeight;++ $this->labelMarginTop = isset($label['padding_top']) ? (float) $label['padding_top'] : $this->labelMarginTop;+ $this->labelMarginRight = isset($label['padding_right']) ? (float) $label['padding_right'] : $this->labelMarginRight;+ $this->labelMarginBottom = isset($label['padding_bottom']) ? (float) $label['padding_bottom'] : $this->labelMarginBottom;+ $this->labelMarginLeft = isset($label['padding_left']) ? (float) $label['padding_left'] : $this->labelMarginLeft;++ $this->supportFields = isset($supports['fields']) ? (int) $supports['fields'] : $this->supportFields;+ $this->supportTitle = (bool) ($supports['title'] ?? false);+ $this->support1DBarcode = (bool) ($supports['barcode_1d'] ?? false);+ $this->support2DBarcode = (bool) ($supports['barcode_2d'] ?? false);+ $this->supportLogo = (bool) ($supports['logo'] ?? false);+ $this->supportAssetTag = (bool) ($supports['asset_tag'] ?? false);++ $this->barcodeSize = isset($content['barcode_size']) ? (float) $content['barcode_size'] : $this->barcodeSize;+ $this->barcodeMargin = isset($content['barcode_margin']) ? (float) $content['barcode_margin'] : $this->barcodeMargin;+ $this->barcode2DSize = isset($content['barcode_2d_size']) ? (float) $content['barcode_2d_size'] : $this->barcode2DSize;+ $this->logoMaxWidth = isset($content['logo_max_width']) ? (float) $content['logo_max_width'] : $this->logoMaxWidth;+ $this->logoMargin = isset($content['logo_margin']) ? (float) $content['logo_margin'] : $this->logoMargin;+ $this->logoHAlign = isset($content['logo_h_align']) ? (string) $content['logo_h_align'] : $this->logoHAlign;+ $this->logoVAlign = isset($content['logo_v_align']) ? (string) $content['logo_v_align'] : $this->logoVAlign;++ $this->tagSize = isset($content['tag_font_size']) ? (float) $content['tag_font_size'] : $this->tagSize;+ $this->tagOffsetX = isset($content['tag_offset_x']) ? (float) $content['tag_offset_x'] : $this->tagOffsetX;+ $this->tagOffsetY = isset($content['tag_offset_y']) ? (float) $content['tag_offset_y'] : $this->tagOffsetY;+ $this->tagAlignment = isset($content['tag_alignment']) ? (string) $content['tag_alignment'] : $this->tagAlignment;+ $this->titleSize = isset($content['title_font_size']) ? (float) $content['title_font_size'] : $this->titleSize;+ $this->labelSize = isset($content['field_label_font_size']) ? (float) $content['field_label_font_size'] : $this->labelSize;+ $this->fieldSize = isset($content['field_value_font_size']) ? (float) $content['field_value_font_size'] : $this->fieldSize;+ $this->textAreaWidth = isset($content['text_area_width']) && $content['text_area_width'] !== '' ? (float) $content['text_area_width'] : $this->textAreaWidth;+ $this->textAreaHeight = isset($content['text_area_height']) && $content['text_area_height'] !== '' ? (float) $content['text_area_height'] : $this->textAreaHeight;++ $this->titleMargin = isset($content['title_margin']) ? (float) $content['title_margin'] : $this->titleMargin;+ $this->titleOffsetX = isset($content['title_offset_x']) ? (float) $content['title_offset_x'] : $this->titleOffsetX;+ $this->labelMargin = isset($content['field_label_margin']) ? (float) $content['field_label_margin'] : $this->labelMargin;+ $this->fieldMargin = isset($content['field_value_margin']) ? (float) $content['field_value_margin'] : $this->fieldMargin;}+public function write($pdf, $record){$pa = $this->getLabelPrintableArea();@@ -795,17 +834,18 @@ abstract class CustomSheetLabel extends CustomLabelreturn $layout;}+protected function boxesOverlap(?array $a, ?array $b): bool{- if (!$a || !$b) {+ if (! $a || ! $b) {return false;}- return !(- $a['x'] + $a['w'] <= $b['x'] ||- $b['x'] + $b['w'] <= $a['x'] ||- $a['y'] + $a['h'] <= $b['y'] ||- $b['y'] + $b['h'] <= $a['y']+ return ! (+ $b['x'] >= $a['x'] + $a['w'] ||+ $a['x'] >= $b['x'] + $b['w'] ||+ $b['y'] >= $a['y'] + $a['h'] ||+ $a['y'] >= $b['y'] + $b['h']);}@@ -847,7 +887,7 @@ abstract class CustomSheetLabel extends CustomLabelprotected function resolveLogoBox($record, array $body): ?array{- if (!$record->has('logo') || !$this->getSupportLogo()) {+ if (! $record->has('logo') || ! $this->getSupportLogo()) {return null;}@@ -864,7 +904,7 @@ abstract class CustomSheetLabel extends CustomLabelprotected function resolve2DBarcodeBox($record, array $body, ?array $logoBox = null): ?array{- if (!$record->has('barcode2d') || !$this->getSupport2DBarcode()) {+ if (! $record->has('barcode2d') || ! $this->getSupport2DBarcode()) {return null;}@@ -890,7 +930,7 @@ abstract class CustomSheetLabel extends CustomLabel$this->getBarcode2DVAlign());- if (!$this->boxesOverlap($altBox, $logoBox)) {+ if (! $this->boxesOverlap($altBox, $logoBox)) {$box = $altBox;}}@@ -900,7 +940,7 @@ abstract class CustomSheetLabel extends CustomLabelprotected function resolveTagBox($record, array $body, ?array $barcode2dBox = null, ?array $logoBox = null): ?array{- if (!$record->has('tag') || !$this->getSupportAssetTag()) {+ if (! $record->has('tag') || ! $this->getSupportAssetTag()) {return null;}@@ -948,7 +988,7 @@ abstract class CustomSheetLabel extends CustomLabelprotected function render1DBarcode($pdf, $record, array $layout): void{- if (!$layout['barcode1d'] || !$record->has('barcode1d')) {+ if (! $layout['barcode1d'] || ! $record->has('barcode1d')) {return;}@@ -965,7 +1005,7 @@ abstract class CustomSheetLabel extends CustomLabelprotected function renderLogo($pdf, $record, array $layout): void{- if (!$layout['logo'] || !$record->has('logo') || !$this->getSupportLogo()) {+ if (! $layout['logo'] || ! $record->has('logo') || ! $this->getSupportLogo()) {return;}@@ -987,7 +1027,7 @@ abstract class CustomSheetLabel extends CustomLabelprotected function render2DBarcode($pdf, $record, array $layout): void{- if (!$layout['barcode2d'] || !$record->has('barcode2d') || !$this->getSupport2DBarcode()) {+ if (! $layout['barcode2d'] || ! $record->has('barcode2d') || ! $this->getSupport2DBarcode()) {return;}@@ -1004,7 +1044,7 @@ abstract class CustomSheetLabel extends CustomLabelprotected function renderTag($pdf, $record, array $layout): void{- if (!$layout['tag'] || !$record->has('tag') || !$this->getSupportAssetTag()) {+ if (! $layout['tag'] || ! $record->has('tag') || ! $this->getSupportAssetTag()) {return;}@@ -1044,7 +1084,7 @@ abstract class CustomSheetLabel extends CustomLabel);}- if (!$layout['fields']) {+ if (! $layout['fields']) {return;}@@ -1059,7 +1099,7 @@ abstract class CustomSheetLabel extends CustomLabel$value = $field['value'] ?? '';if (is_string($label) && trim($label) !== '') {- $label = rtrim($label, ':') . ':';+ $label = rtrim($label, ':').':';}if ($label !== '') {@@ -1113,7 +1153,7 @@ abstract class CustomSheetLabel extends CustomLabel$bottomEdge = $y2;foreach ($boxes as $box) {- if (!$box) {+ if (! $box) {continue;}@@ -1174,4 +1214,4 @@ abstract class CustomSheetLabel extends CustomLabelreturn min($body['w'] * 0.35, $body['w']);}-}\ No newline at end of file+}diff --git a/app/Models/Labels/CustomLabels/PreviewLabel.php b/app/Models/Labels/CustomLabels/PreviewLabel.phpindex 0aafe4471d..8bbe811a10 100644--- a/app/Models/Labels/CustomLabels/PreviewLabel.php+++ b/app/Models/Labels/CustomLabels/PreviewLabel.php@@ -2,7 +2,4 @@namespace App\Models\Labels\CustomLabels;-class PreviewLabel extends CustomSheetLabel-{--}\ No newline at end of file+class PreviewLabel extends CustomSheetLabel {}diff --git a/app/Models/Labels/CustomUserLabel.php b/app/Models/Labels/CustomUserLabel.phpindex e9a9f7f207..cb0815f7a9 100644--- a/app/Models/Labels/CustomUserLabel.php+++ b/app/Models/Labels/CustomUserLabel.php@@ -3,10 +3,11 @@namespace App\Models\Labels;use Illuminate\Database\Eloquent\Model;+use Illuminate\Database\Eloquent\SoftDeletes;use Illuminate\Support\Str;use RecursiveDirectoryIterator;use RecursiveIteratorIterator;-use Illuminate\Database\Eloquent\SoftDeletes;+class CustomUserLabel extends Model{use SoftDeletes;@@ -21,6 +22,7 @@ class CustomUserLabel extends Model'config_snapshot','is_default',];+protected $casts = ['overrides' => 'array','config_snapshot' => 'array',@@ -34,16 +36,15 @@ class CustomUserLabel extends Model* 'DefaultLabel' => App\Models\Labels\DefaultLabel::class,* ]*/-public static function availableBaseLabels(): array{$namespaceRoot = 'App\\Models\\Labels\\';$basePath = app_path('Models/Labels');$allowedRoots = [- $basePath . '/Sheets',- $basePath . '/Tapes',- $basePath . '/DefaultLabel.php',+ $basePath.'/Sheets',+ $basePath.'/Tapes',+ $basePath.'/DefaultLabel.php',];$labels = [];@@ -52,26 +53,26 @@ class CustomUserLabel extends Modelif (is_file($root)) {$files = [new \SplFileInfo($root)];} else {- $files = new \RecursiveIteratorIterator(- new \RecursiveDirectoryIterator($root)+ $files = new RecursiveIteratorIterator(+ new RecursiveDirectoryIterator($root));}foreach ($files as $file) {- if (!$file->isFile() || $file->getExtension() !== 'php') {+ if (! $file->isFile() || $file->getExtension() !== 'php') {continue;}$fullPath = $file->getPathname();- $relativePath = Str::after($fullPath, $basePath . DIRECTORY_SEPARATOR);+ $relativePath = Str::after($fullPath, $basePath.DIRECTORY_SEPARATOR);- $class = $namespaceRoot . str_replace(- [DIRECTORY_SEPARATOR, '.php'],- ['\\', ''],- $relativePath- );+ $class = $namespaceRoot.str_replace(+ [DIRECTORY_SEPARATOR, '.php'],+ ['\\', ''],+ $relativePath+ );- if (!class_exists($class)) {+ if (! class_exists($class)) {continue;}@@ -86,13 +87,10 @@ class CustomUserLabel extends Model/*** Creates a base label instance from a template.- *- * @param string|null $template- * @return object|null*/public static function makeBaseLabel(?string $template): ?object{- if (!$template) {+ if (! $template) {return null;}@@ -101,11 +99,11 @@ class CustomUserLabel extends Model$class = $available[$templateKey] ?? null;- if (!$class || !class_exists($class)) {+ if (! $class || ! class_exists($class)) {return null;}- return new $class();+ return new $class;}/**@@ -113,8 +111,8 @@ class CustomUserLabel extends Model** Only includes values that have been added or overridden.*- * @param array<string, mixed> $finalConfig- * @param array<string, mixed> $baseConfig+ * @param array<string, mixed> $finalConfig+ * @param array<string, mixed> $baseConfig* @return array<string, mixed>*/public static function diffEditorConfig(array $finalConfig, array $baseConfig): array@@ -128,15 +126,16 @@ class CustomUserLabel extends Modelif (is_array($value) && is_array($baseValue)) {$nestedDiff = static::diffEditorConfig($value, $baseValue);- if (!empty($nestedDiff)) {+ if (! empty($nestedDiff)) {$diff[$key] = $nestedDiff;}continue;}- if (!$hasBaseKey) {+ if (! $hasBaseKey) {$diff[$key] = static::normalizeDiffValue($value);+continue;}@@ -155,11 +154,11 @@ class CustomUserLabel extends Modelprotected static function valuesDiffer($value, $baseValue, float $epsilon = 0.001): bool{if (is_bool($value) || is_bool($baseValue)) {- return (bool)$value !== (bool)$baseValue;+ return (bool) $value !== (bool) $baseValue;}if (is_numeric($value) && is_numeric($baseValue)) {- return abs((float)$value - (float)$baseValue) > $epsilon;+ return abs((float) $value - (float) $baseValue) > $epsilon;}return $value !== $baseValue;@@ -172,9 +171,9 @@ class CustomUserLabel extends Modelprotected static function normalizeDiffValue($value){if (is_numeric($value)) {- return round((float)$value, 3);+ return round((float) $value, 3);}return $value;}-}\ No newline at end of file+}diff --git a/app/Models/Labels/Label.php b/app/Models/Labels/Label.phpindex b99d943467..a6a8bb6be4 100644--- a/app/Models/Labels/Label.php+++ b/app/Models/Labels/Label.php@@ -738,7 +738,6 @@ abstract class Label];}-protected function getDimensionsEditorConfig(): array{return [diff --git a/app/Models/Labels/Sheets/Avery/_3490_A.php b/app/Models/Labels/Sheets/Avery/_3490_A.phpindex 5f4850a421..13e0946536 100644--- a/app/Models/Labels/Sheets/Avery/_3490_A.php+++ b/app/Models/Labels/Sheets/Avery/_3490_A.php@@ -114,6 +114,7 @@ class _3490_A extends _3490{return true;}+protected function getContentEditorConfig(): array{return [diff --git a/app/Models/Labels/Sheets/Avery/_5520_B.php b/app/Models/Labels/Sheets/Avery/_5520_B.phpindex e4a4c73891..b347d71c19 100644--- a/app/Models/Labels/Sheets/Avery/_5520_B.php+++ b/app/Models/Labels/Sheets/Avery/_5520_B.php@@ -66,6 +66,7 @@ class _5520_B extends _5520{return self::FIELD_MARGIN;}+public function getUnit(){return 'in';diff --git a/app/Models/Setting.php b/app/Models/Setting.phpindex b00ab1bd6e..f3d4e84025 100755--- a/app/Models/Setting.php+++ b/app/Models/Setting.php@@ -3,6 +3,8 @@namespace App\Models;use App\Helpers\Helper;+use App\Models\Labels\CustomUserLabel;+use App\Models\Labels\Label;use Carbon\Carbon;use Illuminate\Database\Eloquent\Factories\HasFactory;use Illuminate\Database\Eloquent\Model;@@ -12,8 +14,6 @@ use Illuminate\Support\Facades\App;use Illuminate\Support\Facades\Cache;use Illuminate\Support\Facades\Log;use Watson\Validating\ValidatingTrait;-use App\Models\Labels\Label;-use App\Models\Labels\CustomUserLabel;/*** Settings model.@@ -379,12 +379,12 @@ class Setting extends Model{$value = $this->label2_template;- if (!$value) {+ if (! $value) {return 'DefaultLabel';}if (str_starts_with($value, 'custom:')) {- $id = (int)str_replace('custom:', '', $value);+ $id = (int) str_replace('custom:', '', $value);return CustomUserLabel::find($id)?->name ?? $value;}diff --git a/app/Presenters/ConsumablePresenter.php b/app/Presenters/ConsumablePresenter.phpindex aea38c789c..468a2c68d2 100644--- a/app/Presenters/ConsumablePresenter.php+++ b/app/Presenters/ConsumablePresenter.php@@ -128,7 +128,7 @@ class ConsumablePresenter extends Presenter'searchable' => false,'sortable' => false,'switchable' => true,- 'title' => '% ' . trans('general.remaining'),+ 'title' => '% '.trans('general.remaining'),'visible' => true,'formatter' => 'progressBarFormatter',], [diff --git a/app/Presenters/LabelPresenter.php b/app/Presenters/LabelPresenter.phpindex 4d1a5b7272..89628c9c12 100644--- a/app/Presenters/LabelPresenter.php+++ b/app/Presenters/LabelPresenter.php@@ -96,7 +96,7 @@ class LabelPresenter extends Presenter'searchable' => false,'sortable' => false,'formatter' => 'labelActionsFormatter',- ]+ ],];return json_encode($layout);diff --git a/app/Presenters/LicensePresenter.php b/app/Presenters/LicensePresenter.phpindex 683849bf2d..74b88cd42e 100644--- a/app/Presenters/LicensePresenter.php+++ b/app/Presenters/LicensePresenter.php@@ -115,7 +115,7 @@ class LicensePresenter extends Presenter'searchable' => false,'sortable' => false,'switchable' => true,- 'title' => '% ' . trans('general.remaining'),+ 'title' => '% '.trans('general.remaining'),'visible' => true,'formatter' => 'progressBarFormatter',], [diff --git a/app/Presenters/MaintenancesPresenter.php b/app/Presenters/MaintenancesPresenter.phpindex d7588f232e..49633cfa98 100644--- a/app/Presenters/MaintenancesPresenter.php+++ b/app/Presenters/MaintenancesPresenter.php@@ -88,7 +88,7 @@ class MaintenancesPresenter extends Presenter'switchable' => true,'title' => trans('general.model_no'),'visible' => true,- ],[+ ], ['field' => 'assigned_to','searchable' => true,'sortable' => true,diff --git a/app/Rules/AlphaEncrypted.php b/app/Rules/AlphaEncrypted.phpindex e13f677946..92eb074e71 100644--- a/app/Rules/AlphaEncrypted.php+++ b/app/Rules/AlphaEncrypted.php@@ -5,22 +5,24 @@ namespace App\Rules;use Closure;use Illuminate\Contracts\Validation\ValidationRule;use Illuminate\Support\Facades\Crypt;+use Illuminate\Translation\PotentiallyTranslatedString;use Illuminate\Validation\Concerns\ValidatesAttributes;class AlphaEncrypted implements ValidationRule{use ValidatesAttributes;+/*** Run the validation rule.*- * @param \Closure(string): \Illuminate\Translation\PotentiallyTranslatedString $fail+ * @param Closure(string): PotentiallyTranslatedString $fail*/public function validate(string $attribute, mixed $value, Closure $fail): void{try {$attributeName = trim(preg_replace('/_+|snipeit|\d+/', ' ', $attribute));$decrypted = Crypt::decrypt($value);- if (!$this->validateAlpha($attributeName, $decrypted, 'ascii') && !is_null($decrypted)) {+ if (! $this->validateAlpha($attributeName, $decrypted, 'ascii') && ! is_null($decrypted)) {$fail(trans('validation.alpha', ['attribute' => $attributeName]));}} catch (\Exception $e) {diff --git a/app/Rules/AssetCannotBeCheckedOutToNondeployableStatus.php b/app/Rules/AssetCannotBeCheckedOutToNondeployableStatus.phpindex c2c451b82b..fc65f78306 100644--- a/app/Rules/AssetCannotBeCheckedOutToNondeployableStatus.php+++ b/app/Rules/AssetCannotBeCheckedOutToNondeployableStatus.php@@ -4,13 +4,12 @@ namespace App\Rules;use App\Models\Statuslabel;use Closure;-use Illuminate\Contracts\Validation\ValidationRule;use Illuminate\Contracts\Validation\DataAwareRule;-+use Illuminate\Contracts\Validation\ValidationRule;+use Illuminate\Translation\PotentiallyTranslatedString;class AssetCannotBeCheckedOutToNondeployableStatus implements DataAwareRule, ValidationRule{-/*** All of the data under validation.*@@ -18,7 +17,6 @@ class AssetCannotBeCheckedOutToNondeployableStatus implements DataAwareRule, Val*/protected $data = [];-/*** Set the data under validation.*@@ -27,25 +25,25 @@ class AssetCannotBeCheckedOutToNondeployableStatus implements DataAwareRule, Valpublic function setData(array $data): static{$this->data = $data;+return $this;}/*** Run the validation rule.*- * @param \Closure(string): \Illuminate\Translation\PotentiallyTranslatedString $fail+ * @param Closure(string): PotentiallyTranslatedString $fail*/public function validate(string $attribute, mixed $value, Closure $fail): void{// Check to see if any of the assign-ish fields are set- if ((isset($this->data['assigned_to'])) || (isset($this->data['assigned_user'])) || (isset($this->data['assigned_location'])) || (isset($this->data['assigned_asset'])) || (isset($this->data['assigned_type']))) {+ if ((isset($this->data['assigned_to'])) || (isset($this->data['assigned_user'])) || (isset($this->data['assigned_location'])) || (isset($this->data['assigned_asset'])) || (isset($this->data['assigned_type']))) {- if (($value) && ($label = Statuslabel::find($value)) && ($label->getStatuslabelType()!='deployable')) {+ if (($value) && ($label = Statuslabel::find($value)) && ($label->getStatuslabelType() != 'deployable')) {$fail(trans('admin/hardware/form.asset_not_deployable'));}}-}}diff --git a/app/Rules/BooleanEncrypted.php b/app/Rules/BooleanEncrypted.phpindex 06fd370703..e16263080c 100644--- a/app/Rules/BooleanEncrypted.php+++ b/app/Rules/BooleanEncrypted.php@@ -5,6 +5,7 @@ namespace App\Rules;use Closure;use Illuminate\Contracts\Validation\ValidationRule;use Illuminate\Support\Facades\Crypt;+use Illuminate\Translation\PotentiallyTranslatedString;use Illuminate\Validation\Concerns\ValidatesAttributes;class BooleanEncrypted implements ValidationRule@@ -14,7 +15,7 @@ class BooleanEncrypted implements ValidationRule/*** Run the validation rule.*- * @param \Closure(string, ?string=): \Illuminate\Translation\PotentiallyTranslatedString $fail+ * @param Closure(string, ?string=): PotentiallyTranslatedString $fail*/public function validate(string $attribute, mixed $value, Closure $fail): void{@@ -22,7 +23,7 @@ class BooleanEncrypted implements ValidationRule$attributeName = trim(preg_replace('/_+|snipeit|\d+/', ' ', $attribute));$decrypted = Crypt::decrypt($value);- if (!$this->validateBoolean($attributeName, $decrypted) && !is_null($decrypted)) {+ if (! $this->validateBoolean($attributeName, $decrypted) && ! is_null($decrypted)) {$fail(trans('validation.ipv6', ['attribute' => $attributeName]));}} catch (\Exception $e) {diff --git a/app/Rules/DateEncrypted.php b/app/Rules/DateEncrypted.phpindex 73d5cd1b3e..9025f7e70b 100644--- a/app/Rules/DateEncrypted.php+++ b/app/Rules/DateEncrypted.php@@ -5,6 +5,7 @@ namespace App\Rules;use Closure;use Illuminate\Contracts\Validation\ValidationRule;use Illuminate\Support\Facades\Crypt;+use Illuminate\Translation\PotentiallyTranslatedString;use Illuminate\Validation\Concerns\ValidatesAttributes;class DateEncrypted implements ValidationRule@@ -14,14 +15,14 @@ class DateEncrypted implements ValidationRule/*** Run the validation rule.*- * @param \Closure(string): \Illuminate\Translation\PotentiallyTranslatedString $fail+ * @param Closure(string): PotentiallyTranslatedString $fail*/public function validate(string $attribute, mixed $value, Closure $fail): void{try {$attributeName = trim(preg_replace('/_+|snipeit|\d+/', ' ', $attribute));$decrypted = Crypt::decrypt($value);- if (!$this->validateDate($attributeName, $decrypted) && !is_null($decrypted)) {+ if (! $this->validateDate($attributeName, $decrypted) && ! is_null($decrypted)) {$fail(trans('validation.date', ['attribute' => $attributeName]));}} catch (\Exception $e) {diff --git a/app/Rules/EmailEncrypted.php b/app/Rules/EmailEncrypted.phpindex cd0e4ad289..f957e5c0f7 100644--- a/app/Rules/EmailEncrypted.php+++ b/app/Rules/EmailEncrypted.php@@ -5,6 +5,7 @@ namespace App\Rules;use Closure;use Illuminate\Contracts\Validation\ValidationRule;use Illuminate\Support\Facades\Crypt;+use Illuminate\Translation\PotentiallyTranslatedString;use Illuminate\Validation\Concerns\ValidatesAttributes;class EmailEncrypted implements ValidationRule@@ -14,14 +15,14 @@ class EmailEncrypted implements ValidationRule/*** Run the validation rule.*- * @param \Closure(string, ?string=): \Illuminate\Translation\PotentiallyTranslatedString $fail+ * @param Closure(string, ?string=): PotentiallyTranslatedString $fail*/public function validate(string $attribute, mixed $value, Closure $fail): void{try {$attributeName = trim(preg_replace('/_+|snipeit|\d+/', ' ', $attribute));$decrypted = Crypt::decrypt($value);- if (!$this->validateEmail($attribute, $decrypted, []) && !is_null($decrypted)) {+ if (! $this->validateEmail($attribute, $decrypted, []) && ! is_null($decrypted)) {$fail(trans('validation.email', ['attribute' => $attributeName]));}} catch (\Exception $e) {diff --git a/app/Rules/IPEncrypted.php b/app/Rules/IPEncrypted.phpindex 2d64546308..8bfc0cbba8 100644--- a/app/Rules/IPEncrypted.php+++ b/app/Rules/IPEncrypted.php@@ -5,6 +5,7 @@ namespace App\Rules;use Closure;use Illuminate\Contracts\Validation\ValidationRule;use Illuminate\Support\Facades\Crypt;+use Illuminate\Translation\PotentiallyTranslatedString;use Illuminate\Validation\Concerns\ValidatesAttributes;class IPEncrypted implements ValidationRule@@ -14,14 +15,14 @@ class IPEncrypted implements ValidationRule/*** Run the validation rule.*- * @param \Closure(string): \Illuminate\Translation\PotentiallyTranslatedString $fail+ * @param Closure(string): PotentiallyTranslatedString $fail*/public function validate(string $attribute, mixed $value, Closure $fail): void{try {$attributeName = trim(preg_replace('/_+|snipeit|\d+/', ' ', $attribute));$decrypted = Crypt::decrypt($value);- if (!$this->validateIp($attributeName, $decrypted) && !is_null($decrypted)) {+ if (! $this->validateIp($attributeName, $decrypted) && ! is_null($decrypted)) {$fail(trans('validation.ip', ['attribute' => $attributeName]));}} catch (\Exception $e) {diff --git a/app/Rules/IPv4Encrypted.php b/app/Rules/IPv4Encrypted.phpindex 57f36da49a..a46e1c3833 100644--- a/app/Rules/IPv4Encrypted.php+++ b/app/Rules/IPv4Encrypted.php@@ -5,6 +5,7 @@ namespace App\Rules;use Closure;use Illuminate\Contracts\Validation\ValidationRule;use Illuminate\Support\Facades\Crypt;+use Illuminate\Translation\PotentiallyTranslatedString;use Illuminate\Validation\Concerns\ValidatesAttributes;class IPv4Encrypted implements ValidationRule@@ -14,14 +15,14 @@ class IPv4Encrypted implements ValidationRule/*** Run the validation rule.*- * @param \Closure(string): \Illuminate\Translation\PotentiallyTranslatedString $fail+ * @param Closure(string): PotentiallyTranslatedString $fail*/public function validate(string $attribute, mixed $value, Closure $fail): void{try {$attributeName = trim(preg_replace('/_+|snipeit|\d+/', ' ', $attribute));$decrypted = Crypt::decrypt($value);- if (!$this->validateIpv4($attributeName, $decrypted) && !is_null($decrypted)) {+ if (! $this->validateIpv4($attributeName, $decrypted) && ! is_null($decrypted)) {$fail(trans('validation.ipv4', ['attribute' => $attributeName]));}} catch (\Exception $e) {diff --git a/app/Rules/IPv6Encrypted.php b/app/Rules/IPv6Encrypted.phpindex 6bb44fb2d9..bbae8db952 100644--- a/app/Rules/IPv6Encrypted.php+++ b/app/Rules/IPv6Encrypted.php@@ -5,6 +5,7 @@ namespace App\Rules;use Closure;use Illuminate\Contracts\Validation\ValidationRule;use Illuminate\Support\Facades\Crypt;+use Illuminate\Translation\PotentiallyTranslatedString;use Illuminate\Validation\Concerns\ValidatesAttributes;class IPv6Encrypted implements ValidationRule@@ -14,14 +15,14 @@ class IPv6Encrypted implements ValidationRule/*** Run the validation rule.*- * @param \Closure(string): \Illuminate\Translation\PotentiallyTranslatedString $fail+ * @param Closure(string): PotentiallyTranslatedString $fail*/public function validate(string $attribute, mixed $value, Closure $fail): void{try {$attributeName = trim(preg_replace('/_+|snipeit|\d+/', ' ', $attribute));$decrypted = Crypt::decrypt($value);- if (!$this->validateIpv6($attributeName, $decrypted) && !is_null($decrypted)) {+ if (! $this->validateIpv6($attributeName, $decrypted) && ! is_null($decrypted)) {$fail(trans('validation.ipv6', ['attribute' => $attributeName]));}} catch (\Exception $e) {diff --git a/app/Rules/MacEncrypted.php b/app/Rules/MacEncrypted.phpindex c9b125a900..d3be5ed2c4 100644--- a/app/Rules/MacEncrypted.php+++ b/app/Rules/MacEncrypted.php@@ -2,10 +2,10 @@namespace App\Rules;-use App\Models\CustomField;use Closure;use Illuminate\Contracts\Validation\ValidationRule;use Illuminate\Support\Facades\Crypt;+use Illuminate\Translation\PotentiallyTranslatedString;use Illuminate\Validation\Concerns\ValidatesAttributes;class MacEncrypted implements ValidationRule@@ -15,14 +15,14 @@ class MacEncrypted implements ValidationRule/*** Run the validation rule.*- * @param \Closure(string): \Illuminate\Translation\PotentiallyTranslatedString $fail+ * @param Closure(string): PotentiallyTranslatedString $fail*/public function validate(string $attribute, mixed $value, Closure $fail): void{try {$attributeName = trim(preg_replace('/_+|snipeit|\d+/', ' ', $attribute));$decrypted = Crypt::decrypt($value);- if (!$this->validateRegex($attributeName, $decrypted, ['/^[a-fA-F0-9]{2}:[a-fA-F0-9]{2}:[a-fA-F0-9]{2}:[a-fA-F0-9]{2}:[a-fA-F0-9]{2}:[a-fA-F0-9]{2}$/']) && !is_null($decrypted)) {+ if (! $this->validateRegex($attributeName, $decrypted, ['/^[a-fA-F0-9]{2}:[a-fA-F0-9]{2}:[a-fA-F0-9]{2}:[a-fA-F0-9]{2}:[a-fA-F0-9]{2}:[a-fA-F0-9]{2}$/']) && ! is_null($decrypted)) {$fail(trans('validation.mac_address', ['attribute' => $attributeName]));}} catch (\Exception $e) {diff --git a/app/Rules/NumericEncrypted.php b/app/Rules/NumericEncrypted.phpindex abd34916e7..b8b7f56bf1 100644--- a/app/Rules/NumericEncrypted.php+++ b/app/Rules/NumericEncrypted.php@@ -3,10 +3,9 @@namespace App\Rules;use Closure;-use Egulias\EmailValidator\Validation\RFCValidation;-use Illuminate\Contracts\Encryption\DecryptException;use Illuminate\Contracts\Validation\ValidationRule;use Illuminate\Support\Facades\Crypt;+use Illuminate\Translation\PotentiallyTranslatedString;use Illuminate\Validation\Concerns\ValidatesAttributes;class NumericEncrypted implements ValidationRule@@ -16,14 +15,14 @@ class NumericEncrypted implements ValidationRule/*** Run the validation rule.*- * @param \Closure(string): \Illuminate\Translation\PotentiallyTranslatedString $fail+ * @param Closure(string): PotentiallyTranslatedString $fail*/public function validate(string $attribute, mixed $value, Closure $fail): void{try {$attributeName = trim(preg_replace('/_+|snipeit|\d+/', ' ', $attribute));$decrypted = Crypt::decrypt($value);- if (!$this->validateNumeric($attributeName, $decrypted, []) && !is_null($decrypted)) {+ if (! $this->validateNumeric($attributeName, $decrypted, []) && ! is_null($decrypted)) {$fail(trans('validation.numeric', ['attribute' => $attributeName]));}} catch (\Exception $e) {diff --git a/app/Rules/RegexEncrypted.php b/app/Rules/RegexEncrypted.phpindex db72cafa11..47ea02fa00 100644--- a/app/Rules/RegexEncrypted.php+++ b/app/Rules/RegexEncrypted.php@@ -6,6 +6,7 @@ use App\Models\CustomField;use Closure;use Illuminate\Contracts\Validation\ValidationRule;use Illuminate\Support\Facades\Crypt;+use Illuminate\Translation\PotentiallyTranslatedString;use Illuminate\Validation\Concerns\ValidatesAttributes;class RegexEncrypted implements ValidationRule@@ -15,7 +16,7 @@ class RegexEncrypted implements ValidationRule/*** Run the validation rule.*- * @param \Closure(string, ?string=): \Illuminate\Translation\PotentiallyTranslatedString $fail+ * @param Closure(string, ?string=): PotentiallyTranslatedString $fail*/public function validate(string $attribute, mixed $value, Closure $fail): void{@@ -25,7 +26,7 @@ class RegexEncrypted implements ValidationRuletry {$attributeName = trim(preg_replace('/_+|snipeit|\d+/', ' ', $attribute));$decrypted = Crypt::decrypt($value);- if (!$this->validateRegex($attributeName, $decrypted, [$regex]) && !is_null($decrypted)) {+ if (! $this->validateRegex($attributeName, $decrypted, [$regex]) && ! is_null($decrypted)) {$fail(trans('validation.regex', ['attribute' => $attributeName]));}} catch (\Exception $e) {diff --git a/app/Rules/UniqueUndeleted.php b/app/Rules/UniqueUndeleted.phpindex e53274ea8d..d0af846839 100644--- a/app/Rules/UniqueUndeleted.php+++ b/app/Rules/UniqueUndeleted.php@@ -5,21 +5,22 @@ namespace App\Rules;use Closure;use Illuminate\Contracts\Validation\ValidationRule;use Illuminate\Contracts\Validation\ValidatorAwareRule;-use Illuminate\Validation\Validator;use Illuminate\Support\Facades\DB;-use Illuminate\Contracts\Validation\DataAwareRule;+use Illuminate\Translation\PotentiallyTranslatedString;+use Illuminate\Validation\Validator;class UniqueUndeleted implements ValidationRule, ValidatorAwareRule{protected ?Validator $validator = null;+protected array $columns = [];+protected $data = [];public function __construct(- public string $table,- string ...$columns,- )- {+ public string $table,+ string ...$columns,+ ) {$this->columns = $columns;}@@ -27,7 +28,7 @@ class UniqueUndeleted implements ValidationRule, ValidatorAwareRule{$this->validator = $validator;$this->data = $validator->getData();- //TODO - can we somehow grab the ID of the route-model-bound object, and omit its ID?+ // TODO - can we somehow grab the ID of the route-model-bound object, and omit its ID?// to do that, we'd have to know _which_ parameter in the validator is actually the R-M-B'ed// parameter. Or maybe we just change the function signature to let you specify it.@@ -37,13 +38,13 @@ class UniqueUndeleted implements ValidationRule, ValidatorAwareRule/*** Run the validation rule.*- * @param \Closure(string, ?string=): \Illuminate\Translation\PotentiallyTranslatedString $fail+ * @param Closure(string, ?string=): PotentiallyTranslatedString $fail*/public function validate(string $attribute, mixed $value, Closure $fail): void{$query = DB::table($this->table)->whereNull('deleted_at');- $query->where($this->columns[0], '=', $value); //the first column to check- $translation_string = 'validation.unique_undeleted'; //the normal validation string for a single-column check+ $query->where($this->columns[0], '=', $value); // the first column to check+ $translation_string = 'validation.unique_undeleted'; // the normal validation string for a single-column checkforeach (array_slice($this->columns, 1) as $column) {$translation_string = 'validation.two_column_unique_undeleted';$query->where($column, '=', $this->data[$column]);diff --git a/app/Rules/UrlEncrypted.php b/app/Rules/UrlEncrypted.phpindex 61c5f51c90..5a7a5d1f35 100644--- a/app/Rules/UrlEncrypted.php+++ b/app/Rules/UrlEncrypted.php@@ -5,6 +5,7 @@ namespace App\Rules;use Closure;use Illuminate\Contracts\Validation\ValidationRule;use Illuminate\Support\Facades\Crypt;+use Illuminate\Translation\PotentiallyTranslatedString;use Illuminate\Validation\Concerns\ValidatesAttributes;class UrlEncrypted implements ValidationRule@@ -14,14 +15,14 @@ class UrlEncrypted implements ValidationRule/*** Run the validation rule.*- * @param \Closure(string): \Illuminate\Translation\PotentiallyTranslatedString $fail+ * @param Closure(string): PotentiallyTranslatedString $fail*/public function validate(string $attribute, mixed $value, Closure $fail): void{try {$attributeName = trim(preg_replace('/_+|snipeit|\d+/', ' ', $attribute));$decrypted = Crypt::decrypt($value);- if (!$this->validateUrl($attributeName, $decrypted, []) && !is_null($decrypted)) {+ if (! $this->validateUrl($attributeName, $decrypted, []) && ! is_null($decrypted)) {$fail(trans('validation.url', ['attribute' => $attributeName]));}} catch (\Exception $e) {diff --git a/app/Rules/UserCannotSwitchCompaniesIfItemsAssigned.php b/app/Rules/UserCannotSwitchCompaniesIfItemsAssigned.phpindex b31bc91d1b..b5ba48625f 100644--- a/app/Rules/UserCannotSwitchCompaniesIfItemsAssigned.php+++ b/app/Rules/UserCannotSwitchCompaniesIfItemsAssigned.php@@ -1,23 +1,24 @@<?phpnamespace App\Rules;+use App\Models\Setting;-use App\Models\User;use Closure;use Illuminate\Contracts\Validation\ValidationRule;+use Illuminate\Translation\PotentiallyTranslatedString;class UserCannotSwitchCompaniesIfItemsAssigned implements ValidationRule{/*** Run the validation rule.*- * @param \Closure(string): \Illuminate\Translation\PotentiallyTranslatedString $fail+ * @param Closure(string): PotentiallyTranslatedString $fail*/public function validate(string $attribute, mixed $value, Closure $fail): void{$user = request()->route('user');- if (($value) && ($user->allAssignedCount() > 0) && (Setting::getSettings()->full_multiple_companies_support=='1')) {+ if (($value) && ($user->allAssignedCount() > 0) && (Setting::getSettings()->full_multiple_companies_support == '1')) {// Check for assets with a different company_id than the selected company_id$user_assets = $user->assets()->where('assets.company_id', '!=', $value)->count();diff --git a/app/Rules/ValidJson.php b/app/Rules/ValidJson.phpindex 7923494a0a..a79454ac28 100644--- a/app/Rules/ValidJson.php+++ b/app/Rules/ValidJson.php@@ -4,17 +4,18 @@ namespace App\Rules;use Closure;use Illuminate\Contracts\Validation\ValidationRule;+use Illuminate\Translation\PotentiallyTranslatedString;class ValidJson implements ValidationRule{/*** Run the validation rule.*- * @param \Closure(string, ?string=): \Illuminate\Translation\PotentiallyTranslatedString $fail+ * @param Closure(string, ?string=): PotentiallyTranslatedString $fail*/public function validate(string $attribute, mixed $value, Closure $fail): void{- if (!json_validate($value)) {+ if (! json_validate($value)) {$fail(trans('validation.json'));}}diff --git a/app/Services/PredefinedKitCheckoutService.php b/app/Services/PredefinedKitCheckoutService.phpindex f1db8ca452..0f41c756ed 100644--- a/app/Services/PredefinedKitCheckoutService.php+++ b/app/Services/PredefinedKitCheckoutService.php@@ -7,11 +7,11 @@ use App\Models\PredefinedKit;use App\Models\User;use Illuminate\Foundation\Auth\Access\AuthorizesRequests;use Illuminate\Http\Request;-use Illuminate\Support\Facades\Auth;use Illuminate\Support\Facades\DB;/*** Class incapsulates checkout logic for reuse in different controllers+ ** @author [D. Minaev.] [<[email protected]>]*/class PredefinedKitCheckoutService@@ -19,9 +19,9 @@ class PredefinedKitCheckoutServiceuse AuthorizesRequests;/**- * @param Request $request, this function works with fields: checkout_at, expected_checkin, note- * @param PredefinedKit $kit kit for checkout- * @param User $user checkout target+ * @param Request $request, this function works with fields: checkout_at, expected_checkin, note+ * @param PredefinedKit $kit kit for checkout+ * @param User $user checkout target* @return array Empty array if all ok, else [string_error1, string_error2...]*/public function checkout(Request $request, PredefinedKit $kit, User $user)@@ -93,7 +93,7 @@ class PredefinedKitCheckoutService}}if ($quantity > 0) {- $errors[] = trans('admin/kits/general.none_models', ['model'=> $model->name, 'qty' => $model->pivot->quantity]);+ $errors[] = trans('admin/kits/general.none_models', ['model' => $model->name, 'qty' => $model->pivot->quantity]);}}@@ -109,7 +109,7 @@ class PredefinedKitCheckoutServiceforeach ($licenses as $license) {$quantity = $license->pivot->quantity;if ($quantity > count($license->freeSeats)) {- $errors[] = trans('admin/kits/general.none_licenses', ['license'=> $license->name, 'qty' => $license->pivot->quantity]);+ $errors[] = trans('admin/kits/general.none_licenses', ['license' => $license->name, 'qty' => $license->pivot->quantity]);}for ($i = 0; $i < $quantity; $i++) {$seats_to_add[] = $license->freeSeats[$i];@@ -124,7 +124,7 @@ class PredefinedKitCheckoutService$consumables = $kit->consumables()->with('users')->get();foreach ($consumables as $consumable) {if ($consumable->numRemaining() < $consumable->pivot->quantity) {- $errors[] = trans('admin/kits/general.none_consumables', ['consumable'=> $consumable->name, 'qty' => $consumable->pivot->quantity]);+ $errors[] = trans('admin/kits/general.none_consumables', ['consumable' => $consumable->name, 'qty' => $consumable->pivot->quantity]);}}@@ -136,7 +136,7 @@ class PredefinedKitCheckoutService$accessories = $kit->accessories()->with('users')->get();foreach ($accessories as $accessory) {if ($accessory->numRemaining() < $accessory->pivot->quantity) {- $errors[] = trans('admin/kits/general.none_accessory', ['accessory'=> $accessory->name, 'qty' => $accessory->pivot->quantity]);+ $errors[] = trans('admin/kits/general.none_accessory', ['accessory' => $accessory->name, 'qty' => $accessory->pivot->quantity]);}}@@ -175,7 +175,7 @@ class PredefinedKitCheckoutService]);event(new CheckoutableCheckedOut($consumable, $user, $admin, $note));}- //accessories+ // accessoriesforeach ($accessories_to_add as $accessory) {$accessory->assigned_to = $user->id;$accessory->users()->attach($accessory->id, [diff --git a/app/Services/Saml.php b/app/Services/Saml.phpindex 222c2c2ea3..6431296aa3 100644--- a/app/Services/Saml.php+++ b/app/Services/Saml.php@@ -6,13 +6,13 @@ use App\Models\Setting;use App\Models\User;use Exception;use Illuminate\Support\Facades\Cache;+use Illuminate\Support\Facades\Log;use Illuminate\Support\Facades\Session;use OneLogin\Saml2\Auth as OneLogin_Saml2_Auth;use OneLogin\Saml2\IdPMetadataParser as OneLogin_Saml2_IdPMetadataParser;use OneLogin\Saml2\Settings as OneLogin_Saml2_Settings;use OneLogin\Saml2\Utils as OneLogin_Saml2_Utils;use Symfony\Component\HttpKernel\Exception\HttpException;-use Illuminate\Support\Facades\Log;/*** SAML Singleton that builds the settings and loads the onelogin/php-saml library.@@ -134,8 +134,8 @@ class Samltry {$this->_auth = new OneLogin_Saml2_Auth($this->_settings);} catch (Exception $e) {- if ( $this->isEnabled() ) { // $this->loadSettings() initializes this to true if SAML is enabled by settings.- Log::warning('Trying OneLogin_Saml2_Auth failed. Setting SAML enabled to false. OneLogin_Saml2_Auth error message is: '. $e->getMessage());+ if ($this->isEnabled()) { // $this->loadSettings() initializes this to true if SAML is enabled by settings.+ Log::warning('Trying OneLogin_Saml2_Auth failed. Setting SAML enabled to false. OneLogin_Saml2_Auth error message is: '.$e->getMessage());}$this->_enabled = false;}@@ -159,11 +159,11 @@ class Saml$this->_enabled = $setting->saml_enabled == '1';if ($this->isEnabled()) {- //Let onelogin/php-saml know to use 'X-Forwarded-*' headers if it is from a trusted proxy+ // Let onelogin/php-saml know to use 'X-Forwarded-*' headers if it is from a trusted proxyOneLogin_Saml2_Utils::setProxyVars(request()->isFromTrustedProxy());data_set($settings, 'sp.entityId', config('app.url'));- data_set($settings, 'baseurl', config('app.url') . '/saml');+ data_set($settings, 'baseurl', config('app.url').'/saml');data_set($settings, 'sp.assertionConsumerService.url', route('saml.acs'));data_set($settings, 'sp.singleLogoutService.url', route('saml.sls'));data_set($settings, 'sp.x509cert', $setting->saml_sp_x509cert);@@ -259,8 +259,7 @@ class Saml** @since 5.0.0*- * @param string $data- *+ * @param string $data* @return void*/private function saveDataToSession($data)@@ -304,15 +303,15 @@ class Saml** @since 5.0.0*- * @param string $data- *- * @return \App\Models\User+ * @param string $data+ * @return User*/public function samlLogin($data){$this->saveDataToSession($data);$this->loadDataFromSession();$username = $this->getUsername();+return User::where('username', '=', $username)->whereNull('deleted_at')->where('activated', '=', '1')->first();}@@ -337,12 +336,11 @@ class Saml/*** Get a setting.*- * @param string|array|int $key- * @param mixed $default- *+ * @param string|array|int $key+ * @param mixed $default* @return mixed- * @author Johnson Yi <[email protected]>*+ * @author Johnson Yi <[email protected]>*/public function getSetting($key, $default = null){@@ -352,15 +350,14 @@ class Saml/*** Gets the SP metadata. The XML representation.*- * @param bool $alwaysPublishEncryptionCert When 'true', the returned- * metadata will always include an 'encryption' KeyDescriptor. Otherwise,- * the 'encryption' KeyDescriptor will only be included if- * $advancedSettings['security']['wantNameIdEncrypted'] or- * $advancedSettings['security']['wantAssertionsEncrypted'] are enabled.- * @param int|null $validUntil Metadata's valid time- * @param int|null $cacheDuration Duration of the cache in seconds- *- * @return string SP metadata (xml)+ * @param bool $alwaysPublishEncryptionCert When 'true', the returned+ * metadata will always include an 'encryption' KeyDescriptor. Otherwise,+ * the 'encryption' KeyDescriptor will only be included if+ * $advancedSettings['security']['wantNameIdEncrypted'] or+ * $advancedSettings['security']['wantAssertionsEncrypted'] are enabled.+ * @param int|null $validUntil Metadata's valid time+ * @param int|null $cacheDuration Duration of the cache in seconds+ * @return string SP metadata (xml)*/public function getSPMetadata($alwaysPublishEncryptionCert = false, $validUntil = null, $cacheDuration = null){@@ -404,7 +401,7 @@ class Saml/*** Checks if the user is authenticated or not.*- * @return bool True if the user is authenticated+ * @return bool True if the user is authenticated*/public function isAuthenticated(){@@ -414,7 +411,7 @@ class Saml/*** Returns the set of SAML attributes.*- * @return array Attributes of the user.+ * @return array Attributes of the user.*/public function getAttributes(){@@ -424,7 +421,7 @@ class Saml/*** Returns the set of SAML attributes indexed by FriendlyName*- * @return array Attributes of the user.+ * @return array Attributes of the user.*/public function getAttributesWithFriendlyName(){@@ -434,7 +431,7 @@ class Saml/*** Returns the nameID*- * @return string The nameID of the assertion+ * @return string The nameID of the assertion*/public function getNameId(){@@ -444,7 +441,7 @@ class Saml/*** Returns the nameID Format*- * @return string The nameID Format of the assertion+ * @return string The nameID Format of the assertion*/public function getNameIdFormat(){@@ -454,7 +451,7 @@ class Saml/*** Returns the nameID NameQualifier*- * @return string The nameID NameQualifier of the assertion+ * @return string The nameID NameQualifier of the assertion*/public function getNameIdNameQualifier(){@@ -464,7 +461,7 @@ class Saml/*** Returns the nameID SP NameQualifier*- * @return string The nameID SP NameQualifier of the assertion+ * @return string The nameID SP NameQualifier of the assertion*/public function getNameIdSPNameQualifier(){@@ -474,7 +471,7 @@ class Saml/*** Returns the SessionIndex*- * @return string|null The SessionIndex of the assertion+ * @return string|null The SessionIndex of the assertion*/public function getSessionIndex(){@@ -484,7 +481,7 @@ class Saml/*** Returns the SessionNotOnOrAfter*- * @return int|null The SessionNotOnOrAfter of the assertion+ * @return int|null The SessionNotOnOrAfter of the assertion*/public function getSessionExpiration(){diff --git a/app/Services/SnipeTranslator.php b/app/Services/SnipeTranslator.phpindex eb7a9eb044..56843185d3 100644--- a/app/Services/SnipeTranslator.php+++ b/app/Services/SnipeTranslator.php@@ -16,13 +16,13 @@ use Illuminate\Translation\Translator;** This method is called by the trans_choice() helper, which we *do* use a lot.***************************************************************/-class SnipeTranslator extends Translator {-- static $legacy_translation_namespaces = [- "backup::" //Spatie backup uses 'legacy' locale names+class SnipeTranslator extends Translator+{+ public static $legacy_translation_namespaces = [+ 'backup::', // Spatie backup uses 'legacy' locale names];- //This is copied-and-pasted (almost) verbatim from Illuminate\Translation\Translator+ // This is copied-and-pasted (almost) verbatim from Illuminate\Translation\Translatorpublic function choice($key, $number, array $replace = [], $locale = null){$line = $this->get(@@ -36,11 +36,12 @@ class SnipeTranslator extends Translator {$number = count($number);}- if (!isset($replace['count'])) {+ if (! isset($replace['count'])) {$replace['count'] = $number;}- $underscored_locale = str_replace("-","_",$locale); // OUR CHANGE.+ $underscored_locale = str_replace('-', '_', $locale); // OUR CHANGE.+return $this->makeReplacements( // BELOW - that $underscored_locale is the *ONLY* modified part$this->getSelector()->choose($line, $number, $underscored_locale), $replace);@@ -57,7 +58,7 @@ class SnipeTranslator extends Translator {if (preg_match("/^$namespace/", $key)) {$modified_locale = Helper::mapBackToLegacyLocale($locale);$changed_fallback = true;- $this->fallback = 'en'; //TODO - should this be 'env-able'? Or do we just put our foot down and say 'en'?+ $this->fallback = 'en'; // TODO - should this be 'env-able'? Or do we just put our foot down and say 'en'?break;}}@@ -66,8 +67,7 @@ class SnipeTranslator extends Translator {if ($changed_fallback) {$this->fallback = $previous_fallback;}+return $result;}---}\ No newline at end of file+}diff --git a/app/Traits/DisablesDebugbar.php b/app/Traits/DisablesDebugbar.phpindex 839ffb0b97..413647a897 100644--- a/app/Traits/DisablesDebugbar.php+++ b/app/Traits/DisablesDebugbar.php@@ -2,12 +2,14 @@namespace App\Traits;+use Fruitcake\LaravelDebugbar\Facades\Debugbar;+trait DisablesDebugbar{public function disableDebugbar(){- if (class_exists(\Fruitcake\LaravelDebugbar\Facades\Debugbar::class)) {- \Fruitcake\LaravelDebugbar\Facades\Debugbar::disable();+ if (class_exists(Debugbar::class)) {+ Debugbar::disable();}}}diff --git a/app/View/Label.php b/app/View/Label.phpindex c7e3afeed2..7c25b00607 100644--- a/app/View/Label.php+++ b/app/View/Label.php@@ -2,6 +2,8 @@namespace App\View;+use App\Models\Labels\CustomLabels\PreviewLabel;+use App\Models\Labels\CustomUserLabel;use App\Models\Labels\Field;use App\Models\Labels\Label as LabelModel;use App\Models\Labels\Sheet;@@ -10,8 +12,7 @@ use Illuminate\Support\Collection;use Illuminate\Support\Facades\Storage;use Illuminate\Support\Traits\Macroable;use TCPDF;-use App\Models\Labels\CustomUserLabel;-use App\Models\Labels\CustomLabels\PreviewLabel;+class Label implements View{use Macroable { __call as macroCall; }@@ -58,7 +59,7 @@ class Label implements Viewdata_get($customLabel->config_snapshot, 'template', $customLabel->base_label));- $template = new PreviewLabel();+ $template = new PreviewLabel;if ($baseLabel) {$template->seedFromTemplate($baseLabel);diff --git a/bootstrap/app.php b/bootstrap/app.phpindex f2801adf6f..057c8a84eb 100644--- a/bootstrap/app.php+++ b/bootstrap/app.php@@ -1,5 +1,10 @@<?php+use App\Exceptions\Handler;+use App\Http\Kernel;+use Illuminate\Contracts\Debug\ExceptionHandler;+use Illuminate\Foundation\Application;+/*|--------------------------------------------------------------------------| Create The Application@@ -11,7 +16,7 @@|*/-$app = new Illuminate\Foundation\Application(+$app = new Application(realpath(__DIR__.'/../'));@@ -28,7 +33,7 @@ $app = new Illuminate\Foundation\Application($app->singleton(Illuminate\Contracts\Http\Kernel::class,- App\Http\Kernel::class+ Kernel::class);$app->singleton(@@ -37,8 +42,8 @@ $app->singleton();$app->singleton(- Illuminate\Contracts\Debug\ExceptionHandler::class,- App\Exceptions\Handler::class+ ExceptionHandler::class,+ Handler::class);/*diff --git a/database/migrations/2025_07_16_142036_clean_checkout_acceptances.php b/database/migrations/2025_07_16_142036_clean_checkout_acceptances.phpindex b1b5a1c756..1651e9f078 100644--- a/database/migrations/2025_07_16_142036_clean_checkout_acceptances.php+++ b/database/migrations/2025_07_16_142036_clean_checkout_acceptances.php@@ -11,8 +11,8 @@ return new class extends Migrationpublic function up(): void{//- //Artisan::call('snipeit:clean-checkout-acceptances');- // Commenting this out to prevent crashing due to a missing deleted_at clause+ // Artisan::call('snipeit:clean-checkout-acceptances');+ // Commenting this out to prevent crashing due to a missing deleted_at clause}/**diff --git a/database/migrations/2026_03_23_184904_create_custom_labels_table.php b/database/migrations/2026_03_23_184904_create_custom_labels_table.phpindex def10a6986..558e32c4c8 100644--- a/database/migrations/2026_03_23_184904_create_custom_labels_table.php+++ b/database/migrations/2026_03_23_184904_create_custom_labels_table.php@@ -17,7 +17,7 @@ return new class extends Migration$table->string('base_label')->nullable();$table->string('type')->default('sheet');$table->text('overrides')->nullable();- $table->text('config_snapshot')->nullable(); //change to text+ $table->text('config_snapshot')->nullable(); // change to text$table->boolean('is_default')->default(false);$table->timestamps();$table->softDeletes();diff --git a/database/migrations/2026_04_07_141412_add_locations_parent_id_index.php b/database/migrations/2026_04_07_141412_add_locations_parent_id_index.phpindex 9c1a9ff830..796fca1502 100644--- a/database/migrations/2026_04_07_141412_add_locations_parent_id_index.php+++ b/database/migrations/2026_04_07_141412_add_locations_parent_id_index.php@@ -12,7 +12,7 @@ return new class extends Migrationpublic function up(): void{Schema::table('locations', function (Blueprint $table) {- $table->index(['parent_id','deleted_at']);+ $table->index(['parent_id', 'deleted_at']);});}@@ -22,7 +22,7 @@ return new class extends Migrationpublic function down(): void{Schema::table('locations', function (Blueprint $table) {- $table->dropIndex(['parent_id','deleted_at']);+ $table->dropIndex(['parent_id', 'deleted_at']);});}};diff --git a/database/migrations/2026_04_07_141930_accessories_checkout_assigned_to_index.php b/database/migrations/2026_04_07_141930_accessories_checkout_assigned_to_index.phpindex 4e723570ef..1eff042df3 100644--- a/database/migrations/2026_04_07_141930_accessories_checkout_assigned_to_index.php+++ b/database/migrations/2026_04_07_141930_accessories_checkout_assigned_to_index.php@@ -12,7 +12,7 @@ return new class extends Migrationpublic function up(): void{Schema::table('accessories_checkout', function (Blueprint $table) {- $table->index(['assigned_to','assigned_type']);+ $table->index(['assigned_to', 'assigned_type']);});}@@ -22,7 +22,7 @@ return new class extends Migrationpublic function down(): void{Schema::table('accessories_checkout', function (Blueprint $table) {- $table->dropIndex(['assigned_to','assigned_type']);+ $table->dropIndex(['assigned_to', 'assigned_type']);});}};diff --git a/resources/views/paginator/simple.php b/resources/views/paginator/simple.phpindex 9cecbd3d77..9981cc0104 100755--- a/resources/views/paginator/simple.php+++ b/resources/views/paginator/simple.php@@ -2,7 +2,7 @@use Illuminate\Pagination\BootstrapPresenter;- $presenter = new BootstrapPresenter($paginator);+$presenter = new BootstrapPresenter($paginator);$trans = $environment->getTranslator();?>diff --git a/resources/views/paginator/slider.php b/resources/views/paginator/slider.phpindex 0713368c6a..927829dca6 100755--- a/resources/views/paginator/slider.php+++ b/resources/views/paginator/slider.php@@ -2,7 +2,7 @@use Illuminate\Pagination\BootstrapPresenter;- $presenter = new BootstrapPresenter($paginator);+$presenter = new BootstrapPresenter($paginator);?><div class="pagination">diff --git a/resources/views/partials/bootstrap-table.blade.php b/resources/views/partials/bootstrap-table.blade.phpindex 1aa5fe8eca..d0b72e03f5 100644--- a/resources/views/partials/bootstrap-table.blade.php+++ b/resources/views/partials/bootstrap-table.blade.php@@ -1929,12 +1929,13 @@var encodedJson = encodeURIComponent(JSON.stringify(row.config_snapshot || {}, null, 2));actions += '<button type="button" '- + 'class="btn btn-primary btn-sm copy-label-json hidden-print" '+ + 'class="btn btn-primary btn-sm export-label-json hidden-print" '+ 'data-json="' + encodedJson + '" '- + 'title="Share Label" '+ + 'data-name="' + encodeURIComponent(row.name || "label") + '" '+ + 'title="Export Label" '+ 'data-tooltip="true">'- + '<i class="fa-solid fa-up-right-from-square"></i>'- + '<span class="sr-only">Share Label</span>'+ + '<i class="fa-solid fa-file-export"></i>'+ + '<span class="sr-only">Export Label</span>'+ '</button> ';// Delete buttondiff --git a/resources/views/settings/label-edit.blade.php b/resources/views/settings/label-edit.blade.phpindex 9de36cd035..73f262a59b 100644--- a/resources/views/settings/label-edit.blade.php+++ b/resources/views/settings/label-edit.blade.php@@ -71,6 +71,14 @@.label-form-footer {grid-column: 1 / -1;}++ .label-form-header {+ position: sticky;+ top: 0;+ z-index: 15;+ padding: 10px 0;+ grid-column: 1 / -1;+ }</style><div class="col-sm-10 col-sm-offset-1 col-md-10 col-md-offset-1">@@ -103,7 +111,7 @@$defaultName = $selectedLabel ? 'Copy of '.$selectedLabel : 'Custom Label';@endphp- <div class="form-group" style="margin-left: 0; margin-right: 0;">+ <div class="form-group"><label for="name" style="display:block; margin-bottom:6px;">Label Name</label>@@ -305,17 +313,23 @@</div>@endif- <div class="label-form-footer">- <div class="box-footer clearfix" style="padding-left: 0; padding-right: 0;">- <div class="pull-right">- <button type="submit" class="btn btn-success">- <i class="fa fa-check"></i> Save- </button>- </div>- </div>- </div>+</div></form>++ </div>+ </div>+ </div>+ <div class="label-form-footer">+ <div class="box-footer clearfix" style="padding-left: 0; padding-right: 0;">+ <div class="pull-right">+ <button+ type="submit"+ form="label-customizer-form"+ class="btn btn-success"+ >+ <i class="fa fa-check"></i> Save+ </button></div></div></div>diff --git a/resources/views/settings/labels.blade.php b/resources/views/settings/labels.blade.phpindex 0753bcc697..f5a0b4179a 100644--- a/resources/views/settings/labels.blade.php+++ b/resources/views/settings/labels.blade.php@@ -22,7 +22,6 @@.import-toggle .btn {background-color: #f5f5f5; /* light neutral */color: #333;- border-color: #ccc;}.import-toggle .btn:hover {@@ -32,7 +31,16 @@.import-toggle .btn.active {background-color: #337ab7; /* Bootstrap primary */color: #fff;- border-color: #2e6da4;+ }++ .import-toggle .btn:focus,+ .import-toggle .btn:active:focus,+ .import-toggle .btn.active:focus,+ .import-toggle .btn.focus,+ .import-toggle .btn.active.focus {+ outline: none !important;+ box-shadow: none !important;+ -webkit-box-shadow: none !important;}</style>@@ -69,9 +77,6 @@<p class="help-block">{!! trans('admin/settings/general.label2_enable_help') !!}</p>---</div></div>@@ -85,33 +90,42 @@</div><div class="col-md-7">- <input type="hidden" name="import_method" id="import_method" value="text"- form="import-label-form">+ <input+ type="hidden"+ name="import_method"+ id="import_method"+ value="json"+ form="import-label-form"+ ><div class="btn-group import-toggle" role="group">- <button type="button"+ <button+ type="button"class="btn btn-primary import-toggle-btn active"- data-method="json">+ data-method="json"+ >JSON</button>- <button type="button"+ <button+ type="button"class="btn btn-default import-toggle-btn"- data-method="text">+ data-method="text"+ >Text</button></div>- <div id="text-input-group" style="margin-top:10px;">+ <div id="text-input-group" style="display:none; margin-top:10px;"><div class="import-inline-row">- <textarea- name="config_snapshot"- form="import-label-form"- id="config_snapshot"- class="form-control"- rows="4"- placeholder="Paste label config JSON here"- >{{ old('config_snapshot') }}</textarea>+ <textarea+ name="config_snapshot"+ form="import-label-form"+ id="config_snapshot"+ class="form-control"+ rows="4"+ placeholder="Paste label config JSON here"+ >{{ old('config_snapshot') }}</textarea><buttontype="submit"@@ -127,7 +141,7 @@<p id="json-validation-message" class="help-block" style="display:none;"></p></div>- <div id="json-input-group" style="display:none; margin-top:10px;">+ <div id="json-input-group" style="margin-top:10px;"><div class="input-group"><inputtype="file"@@ -139,20 +153,32 @@><span class="input-group-btn">- <button- type="submit"- form="import-label-form"- id="import-file-button"- class="btn btn-primary"- disabled- >- Import- </button>- </span>+ <button+ type="submit"+ form="import-label-form"+ id="import-file-button"+ class="btn btn-primary"+ disabled+ >+ Import+ </button>+ </span></div></div>- {!! $errors->first('config_snapshot', '<span class="alert-msg">:message</span>') !!}+ @if ($errors->has('config_snapshot'))+ <ul class="alert-msg">+ @foreach ((array) $errors->get('config_snapshot') as $message)+ @if (is_array($message))+ @foreach ($message as $line)+ <li>{{ $line }}</li>+ @endforeach+ @else+ <li>{{ $message }}</li>+ @endif+ @endforeach+ </ul>+ @endif</div></div><!-- New Settings -->@@ -813,6 +839,28 @@}, 1500);}});+ $(document).on('click', '.export-label-json', function () {++ const json = decodeURIComponent($(this).data('json'));+ const name = decodeURIComponent($(this).data('name'));++ const blob = new Blob([json], {+ type: 'application/json;charset=utf-8'+ });++ const url = window.URL.createObjectURL(blob);+ const a = document.createElement('a');+ const safeName = name.replace(/[^\w\-]+/g, '_');++ a.href = url;+ a.download = `${safeName}.json`;++ document.body.appendChild(a);+ a.click();++ document.body.removeChild(a);+ window.URL.revokeObjectURL(url);+ });$('.import-toggle-btn').on('click', function () {const method = $(this).data('method');@@ -830,6 +878,37 @@$('#text-input-group').toggle(method === 'text');$('#json-input-group').toggle(method === 'json');});++ $('#config_file').on('change', function () {+ const hasFile = this.files && this.files.length > 0;++ $('#import-file-button').prop('disabled', !hasFile);+ });++ $('#config_snapshot').on('input', function () {++ const value = $(this).val().trim();++ try {+ JSON.parse(value);++ $('#import-text-button').prop('disabled', false);++ $('#json-validation-message')+ .hide()+ .text('');++ } catch (e) {++ $('#import-text-button').prop('disabled', true);++ $('#json-validation-message')+ .show()+ .addClass('text-danger')+ .text('Invalid JSON');+ }+ });+</script>{{-- Can't use @script here because we're not in a livewire component so let's manually load --}}@livewireScriptsdiff --git a/routes/console.php b/routes/console.phpindex 2413e4b189..a4c876ae04 100644--- a/routes/console.php+++ b/routes/console.php@@ -20,7 +20,7 @@ Artisan::command('inspire', function () {Artisan::command('snipeit:travisci-install', function () {if (! Setting::setupCompleted()) {- $settings = new Setting();+ $settings = new Setting;$settings->site_name = 'test-ci';$settings->alert_email = '[email protected]';$settings->alerts_enabled = 1;diff --git a/routes/scim.php b/routes/scim.phpindex d8d8a8fdbc..7aeeda30a8 100644--- a/routes/scim.php+++ b/routes/scim.php@@ -3,20 +3,19 @@use ArieTimmerman\Laravel\SCIMServer\RouteProvider as SCIMRouteProvider;use Illuminate\Support\Facades\Route;-/*|--------------------------------------------------------------------------| SCIM Routes|--------------------------------------------------------------------------|-| These are the routes that we have to explicitly inject from the+| These are the routes that we have to explicitly inject from the| laravel-scim-server project, which gives Snipe-IT SCIM support|*/SCIMRouteProvider::publicRoutes(); // Make sure to load public routes *FIRST*-Route::middleware(['auth:api','authorize:superadmin'])->group(function () {+Route::middleware(['auth:api', 'authorize:superadmin'])->group(function () {SCIMRouteProvider::routes([/*@@ -30,7 +29,7 @@ Route::middleware(['auth:api','authorize:superadmin'])->group(function () {* like 4 hours of your life trying to figure out why the public routes* aren't quite working right. Ask me how I know (BMW, 3/19/2022)*/- 'public_routes' => false+ 'public_routes' => false,]);diff --git a/routes/web.php b/routes/web.phpindex 37f8dcd9fc..f7a6f61815 100644--- a/routes/web.php+++ b/routes/web.php@@ -30,7 +30,6 @@ use App\Http\Controllers\SuppliersController;use App\Http\Controllers\UploadedFilesController;use App\Http\Controllers\ViewAssetsController;use App\Livewire\Importer;-use App\Mail\CheckoutComponentMail;use App\Models\ReportTemplate;use Illuminate\Support\Facades\Route;use Tabuna\Breadcrumbs\Trail;@@ -220,7 +219,7 @@ Route::group(['prefix' => 'admin', 'middleware' => ['auth', 'authorize:superuser->name('settings.labels.destroy');Route::post('/settings/labels/import', [LabelsController::class, 'import'])->name('settings.labels.import');-+Route::get('ldap', [SettingsController::class, 'getLdapSettings'])->name('settings.ldap.index')->breadcrumbs(fn (Trail $trail) => $trail->parent('settings.index')diff --git a/routes/web/accessories.php b/routes/web/accessories.phpindex 15b89572a0..71b929101e 100644--- a/routes/web/accessories.php+++ b/routes/web/accessories.php@@ -28,8 +28,8 @@ Route::group(['prefix' => 'accessories', 'middleware' => ['auth']], function ())->name('accessories.checkin.store');Route::get('{accessory}/clone',- [Accessories\AccessoriesController::class, 'getClone']- )->name('clone/accessories');+ [Accessories\AccessoriesController::class, 'getClone']+ )->name('clone/accessories');Route::post('{accessory}/clone',[Accessories\AccessoriesController::class, 'postCreate']@@ -38,5 +38,5 @@ Route::group(['prefix' => 'accessories', 'middleware' => ['auth']], function ()});Route::resource('accessories', Accessories\AccessoriesController::class, [- 'middleware' => ['auth']+ 'middleware' => ['auth'],]);diff --git a/routes/web/components.php b/routes/web/components.phpindex fa66ab5ad6..117c559d4b 100644--- a/routes/web/components.php+++ b/routes/web/components.php@@ -29,8 +29,6 @@ Route::group(['prefix' => 'components', 'middleware' => ['auth']], function () {[Components\ComponentsController::class, 'getClone'])->name('components.clone.create');--});Route::resource('components', Components\ComponentsController::class, [diff --git a/routes/web/consumables.php b/routes/web/consumables.phpindex 53ec09425e..d27eb45829 100644--- a/routes/web/consumables.php+++ b/routes/web/consumables.php@@ -3,8 +3,6 @@use App\Http\Controllers\Consumables;use Illuminate\Support\Facades\Route;--Route::group(['prefix' => 'consumables', 'middleware' => ['auth']], function () {Route::get('{consumablesID}/checkout',@@ -16,14 +14,12 @@ Route::group(['prefix' => 'consumables', 'middleware' => ['auth']], function ()[Consumables\ConsumableCheckoutController::class, 'store'])->name('consumables.checkout.store');-Route::get('{consumable}/clone',[Consumables\ConsumablesController::class, 'clone'])->name('consumables.clone.create');-});-+Route::resource('consumables', Consumables\ConsumablesController::class, ['middleware' => ['auth'],'parameters' => ['consumable' => 'consumable_id'],diff --git a/routes/web/fields.php b/routes/web/fields.phpindex 529842fdc9..bafc0f5cda 100644--- a/routes/web/fields.php+++ b/routes/web/fields.php@@ -8,9 +8,7 @@ use Illuminate\Support\Facades\Route;* Custom Fields Routes*/---Route::group([ 'prefix' => 'fields','middleware' => ['auth'] ], function () {+Route::group(['prefix' => 'fields', 'middleware' => ['auth']], function () {Route::post('required/{fieldset_id}/{field_id}',@@ -32,16 +30,14 @@ Route::group([ 'prefix' => 'fields','middleware' => ['auth'] ], function () {[CustomFieldsetsController::class, 'associate'])->name('fieldsets.associate');-Route::resource('fieldsets', CustomFieldsetsController::class, ['parameters' => ['fieldset' => 'fieldset',- 'field' => 'field_id'+ 'field' => 'field_id',],- 'except' => ['show', 'view']+ 'except' => ['show', 'view'],]);-// This is a shim to handle bootstrap tables// @todo: normalize this in the JSRoute::get(@@ -58,6 +54,5 @@ Route::group([ 'prefix' => 'fields','middleware' => ['auth'] ], function () {Route::resource('fields', CustomFieldsController::class,['middleware' => ['auth'],- 'except' => ['show', 'view']+ 'except' => ['show', 'view'],]);-diff --git a/routes/web/hardware.php b/routes/web/hardware.phpindex c2aed9a915..6460e32159 100644--- a/routes/web/hardware.php+++ b/routes/web/hardware.php@@ -1,14 +1,14 @@<?php-use App\Http\Controllers\MaintenancesController;+use App\Http\Controllers\Assets\AssetCheckinController;+use App\Http\Controllers\Assets\AssetCheckoutController;use App\Http\Controllers\Assets\AssetsController;use App\Http\Controllers\Assets\BulkAssetsController;-use App\Http\Controllers\Assets\AssetCheckoutController;-use App\Http\Controllers\Assets\AssetCheckinController;+use App\Http\Controllers\MaintenancesController;+use App\Models\Asset;use App\Models\Setting;-use Tabuna\Breadcrumbs\Trail;use Illuminate\Support\Facades\Route;-use App\Models\Asset;+use Tabuna\Breadcrumbs\Trail;/*|--------------------------------------------------------------------------@@ -21,51 +21,45 @@ use App\Models\Asset;Route::group(['prefix' => 'hardware',- 'middleware' => ['auth'],+ 'middleware' => ['auth'],],-+function () {-+Route::get('bulkaudit', [AssetsController::class, 'quickScan'])->name('assets.bulkaudit')- ->breadcrumbs(fn (Trail $trail) =>- $trail->parent('hardware.index')+ ->breadcrumbs(fn (Trail $trail) => $trail->parent('hardware.index')->push(trans('general.bulkaudit'), route('asset.import-history')));Route::get('quickscancheckin', [AssetsController::class, 'quickScanCheckin'])->name('hardware/quickscancheckin')- ->breadcrumbs(fn (Trail $trail) =>- $trail->parent('hardware.index')+ ->breadcrumbs(fn (Trail $trail) => $trail->parent('hardware.index')->push('Quickscan Checkin', route('hardware/quickscancheckin')));Route::get('requested', [AssetsController::class, 'getRequestedIndex'])->name('assets.requested')- ->breadcrumbs(fn (Trail $trail) =>- $trail->parent('hardware.index')+ ->breadcrumbs(fn (Trail $trail) => $trail->parent('hardware.index')->push(trans('admin/hardware/general.requested'), route('assets.requested')));Route::get('audit/due', [AssetsController::class, 'dueForAudit'])->name('assets.audit.due')- ->breadcrumbs(fn (Trail $trail) =>- $trail->parent('hardware.index')+ ->breadcrumbs(fn (Trail $trail) => $trail->parent('hardware.index')->push(trans_choice('general.audit_due_days', Setting::getSettings()->audit_warning_days, ['days' => Setting::getSettings()->audit_warning_days]), route('assets.audit.due')));Route::get('checkins/due',[AssetsController::class, 'dueForCheckin'])->name('assets.checkins.due')- ->breadcrumbs(fn (Trail $trail) =>- $trail->parent('hardware.index')+ ->breadcrumbs(fn (Trail $trail) => $trail->parent('hardware.index')->push(trans_choice('general.checkin_due_days', Setting::getSettings()->due_checkin_days, ['days' => Setting::getSettings()->due_checkin_days]), route('assets.audit.due')));-+Route::get('{asset}/audit', [AssetsController::class, 'audit'])->name('asset.audit.create')- ->breadcrumbs(fn (Trail $trail, Asset $asset) =>- $trail->parent('hardware.show', $asset)+ ->breadcrumbs(fn (Trail $trail, Asset $asset) => $trail->parent('hardware.show', $asset)->push(trans('general.audit')));@@ -75,8 +69,7 @@ Route::group(Route::get('history', [AssetsController::class, 'getImportHistory'])->name('asset.import-history')- ->breadcrumbs(fn (Trail $trail) =>- $trail->parent('hardware.index')+ ->breadcrumbs(fn (Trail $trail) => $trail->parent('hardware.index')->push(trans('general.import-history'), route('asset.import-history')));@@ -102,8 +95,7 @@ Route::group(Route::get('{asset}/checkout', [AssetCheckoutController::class, 'create'])->name('hardware.checkout.create')- ->breadcrumbs(fn (Trail $trail, Asset $asset) =>- $trail->parent('hardware.show', $asset)+ ->breadcrumbs(fn (Trail $trail, Asset $asset) => $trail->parent('hardware.show', $asset)->push(trans('admin/hardware/general.checkout'), route('hardware.index')));@@ -114,10 +106,9 @@ Route::group(Route::get('{asset}/checkin/{backto?}',[AssetCheckinController::class, 'create'])->name('hardware.checkin.create')- ->breadcrumbs(fn (Trail $trail, Asset $asset) =>- $trail->parent('hardware.show', $asset)- ->push(trans('admin/hardware/general.checkin'), route('hardware.index'))- );+ ->breadcrumbs(fn (Trail $trail, Asset $asset) => $trail->parent('hardware.show', $asset)+ ->push(trans('admin/hardware/general.checkin'), route('hardware.index'))+ );Route::post('{assetId}/checkin/{backto?}',[AssetCheckinController::class, 'store']@@ -144,9 +135,8 @@ Route::group('bulkedit',[BulkAssetsController::class, 'edit'])->name('hardware.bulkedit.show')- ->breadcrumbs(fn (Trail $trail) =>- $trail->parent('hardware.index')- ->push(trans('general.bulk_edit'), route('hardware.index')));+ ->breadcrumbs(fn (Trail $trail) => $trail->parent('hardware.index')+ ->push(trans('general.bulk_edit'), route('hardware.index')));Route::post('bulkdelete',@@ -166,8 +156,7 @@ Route::group(// Bulk checkout / checkinRoute::get('bulkcheckout', [BulkAssetsController::class, 'showCheckout'])->name('hardware.bulkcheckout.show')- ->breadcrumbs(fn (Trail $trail) =>- $trail->parent('hardware.index')+ ->breadcrumbs(fn (Trail $trail) => $trail->parent('hardware.index')->push(trans('admin/hardware/general.bulk_checkout'), route('hardware.index')));@@ -178,15 +167,14 @@ Route::group(});Route::resource('hardware',- AssetsController::class,- ['middleware' => ['auth']-])->parameters(['hardware' => 'asset'])->withTrashed();-+ AssetsController::class,+ ['middleware' => ['auth'],+ ])->parameters(['hardware' => 'asset'])->withTrashed();// Asset MaintenancesRoute::resource('maintenances',MaintenancesController::class,- ['middleware' => ['auth']+ ['middleware' => ['auth'],])->parameters(['maintenance' => 'maintenance', 'asset' => 'asset_id']);Route::get('ht/{any?}',diff --git a/routes/web/kits.php b/routes/web/kits.phpindex abd2d75266..37cb910054 100644--- a/routes/web/kits.php+++ b/routes/web/kits.php@@ -21,8 +21,7 @@ Route::group(['prefix' => 'kits/{kit}', 'middleware' => ['auth']], function () {Route::get('licenses/{license_id}/edit', [Kits\PredefinedKitsController::class, 'editLicense'])->name('kits.licenses.edit')- ->breadcrumbs(fn (Trail $trail) =>- $trail->parent('settings.index')+ ->breadcrumbs(fn (Trail $trail) => $trail->parent('settings.index')->push(trans('admin/settings/general.backups'), route('kits.licenses.edit')));Route::delete('licenses/{license_id}',@@ -46,7 +45,7 @@ Route::group(['prefix' => 'kits/{kit}', 'middleware' => ['auth']], function () {// ConsumablesRoute::put('consumables/{consumable_id}',[Kits\PredefinedKitsController::class, 'updateConsumable']- )/*->parameters([2 => 'kit_id', 1 => 'consumable_id'])*/->name('kits.consumables.update');+ )/* ->parameters([2 => 'kit_id', 1 => 'consumable_id']) */ ->name('kits.consumables.update');Route::get('consumables/{consumable_id}/edit',[Kits\PredefinedKitsController::class, 'editConsumable']@@ -59,7 +58,7 @@ Route::group(['prefix' => 'kits/{kit}', 'middleware' => ['auth']], function () {// AccessoriesRoute::put('accessories/{accessory_id}',[Kits\PredefinedKitsController::class, 'updateAccessory']- )/*->parameters([2 => 'kit_id', 1 => 'accessory_id'])*/->name('kits.accessories.update');+ )/* ->parameters([2 => 'kit_id', 1 => 'accessory_id']) */ ->name('kits.accessories.update');Route::get('accessories/{accessory_id}/edit', [Kits\PredefinedKitsController::class, 'editAccessory'])->name('kits.accessories.edit');@@ -69,8 +68,7 @@ Route::group(['prefix' => 'kits/{kit}', 'middleware' => ['auth']], function () {Route::get('checkout', [Kits\CheckoutKitController::class, 'showCheckout'])->name('kits.checkout.show')- ->breadcrumbs(fn (Trail $trail, PredefinedKit $kit) =>- $trail->parent('kits.show', $kit)+ ->breadcrumbs(fn (Trail $trail, PredefinedKit $kit) => $trail->parent('kits.show', $kit)->push(trans('general.checkout'), route('kits.checkout.show', $kit)));Route::post('checkout', [Kits\CheckoutKitController::class, 'store'])@@ -81,4 +79,3 @@ Route::group(['prefix' => 'kits/{kit}', 'middleware' => ['auth']], function () {Route::resource('kits', Kits\PredefinedKitsController::class, ['middleware' => ['auth'],]);-diff --git a/routes/web/licenses.php b/routes/web/licenses.phpindex 548776cb28..4a21d9fc5d 100644--- a/routes/web/licenses.php+++ b/routes/web/licenses.php@@ -1,9 +1,9 @@<?phpuse App\Http\Controllers\Licenses;-use Illuminate\Support\Facades\Route;use App\Models\License;use App\Models\LicenseSeat;+use Illuminate\Support\Facades\Route;use Tabuna\Breadcrumbs\Trail;// Licenses@@ -12,20 +12,18 @@ Route::group(['prefix' => 'licenses', 'middleware' => ['auth']], function () {Route::get('{license}/checkout/{seatId?}', [Licenses\LicenseCheckoutController::class, 'create'])->name('licenses.checkout')- ->breadcrumbs(fn (Trail $trail, License $license) =>- $trail->parent('licenses.show', $license)+ ->breadcrumbs(fn (Trail $trail, License $license) => $trail->parent('licenses.show', $license)->push(trans('general.checkout'), route('licenses.checkout', $license)));Route::post('{licenseId}/checkout/{seatId?}',[Licenses\LicenseCheckoutController::class, 'store']- ); //name() would duplicate here, so we skip it.+ ); // name() would duplicate here, so we skip it.Route::get('{licenseSeat}/checkin/{backto?}', [Licenses\LicenseCheckinController::class, 'create'])->name('licenses.checkin')- ->breadcrumbs(fn (Trail $trail, LicenseSeat $licenseSeat) =>- $trail->parent('licenses.show', $licenseSeat->license)+ ->breadcrumbs(fn (Trail $trail, LicenseSeat $licenseSeat) => $trail->parent('licenses.show', $licenseSeat->license)->push(trans('general.checkin'), route('licenses.checkin', $licenseSeat)));@@ -47,7 +45,7 @@ Route::group(['prefix' => 'licenses', 'middleware' => ['auth']], function () {'export',[Licenses\LicensesController::class,- 'getExportLicensesCsv'+ 'getExportLicensesCsv',])->name('licenses.export');});diff --git a/routes/web/locations.php b/routes/web/locations.phpindex 882bd5c92d..043109ff13 100644--- a/routes/web/locations.php+++ b/routes/web/locations.php@@ -6,32 +6,32 @@ use Illuminate\Support\Facades\Route;Route::group(['prefix' => 'locations', 'middleware' => ['auth']], function () {Route::post(- 'bulkdelete',- [LocationsController::class, 'postBulkDelete']+ 'bulkdelete',+ [LocationsController::class, 'postBulkDelete'])->name('locations.bulkdelete.show');Route::post(- 'bulkedit',- [LocationsController::class, 'postBulkDeleteStore']+ 'bulkedit',+ [LocationsController::class, 'postBulkDeleteStore'])->name('locations.bulkdelete.store');Route::post(- '{location}/restore',- [LocationsController::class, 'postRestore']+ '{location}/restore',+ [LocationsController::class, 'postRestore'])->name('locations.restore')->withTrashed();Route::get('{locationId}/clone',- [LocationsController::class, 'getClone']+ [LocationsController::class, 'getClone'])->name('clone/location');Route::get(- '{locationId}/printassigned',- [LocationsController::class, 'print_assigned']+ '{locationId}/printassigned',+ [LocationsController::class, 'print_assigned'])->name('locations.print_assigned');Route::get(- '{locationId}/printallassigned',- [LocationsController::class, 'print_all_assigned']+ '{locationId}/printallassigned',+ [LocationsController::class, 'print_all_assigned'])->name('locations.print_all_assigned');});diff --git a/routes/web/models.php b/routes/web/models.phpindex 1b70713bff..05b50d4714 100644--- a/routes/web/models.php+++ b/routes/web/models.php@@ -7,81 +7,76 @@ use Tabuna\Breadcrumbs\Trail;// Asset Model Management-Route::group(['prefix' => 'models', 'middleware' => ['auth']], function () {Route::get('{model}/clone',[- AssetModelsController::class,- 'getClone'+ AssetModelsController::class,+ 'getClone',])->name('models.clone.create')->withTrashed()- ->breadcrumbs(fn (Trail $trail) =>- $trail->parent('models.index')+ ->breadcrumbs(fn (Trail $trail) => $trail->parent('models.index')->push(trans('admin/models/table.clone'), route('models.index')));Route::post('{model}/clone',[- AssetModelsController::class,- 'postCreate'+ AssetModelsController::class,+ 'postCreate',])->name('models.clone.store')->withTrashed();Route::get('{modelId}/view',[- AssetModelsController::class,- 'getView'+ AssetModelsController::class,+ 'getView',])->name('view/model');Route::post('{modelID}/restore',[- AssetModelsController::class,- 'getRestore'+ AssetModelsController::class,+ 'getRestore',])->name('models.restore.store');Route::get('{modelId}/custom_fields',[- AssetModelsController::class,- 'getCustomFields'+ AssetModelsController::class,+ 'getCustomFields',])->name('custom_fields/model');Route::post('bulkedit',[- BulkAssetModelsController::class,- 'edit'+ BulkAssetModelsController::class,+ 'edit',])->name('models.bulkedit.index')- ->breadcrumbs(fn (Trail $trail) =>- $trail->parent('models.index')- ->push(trans('general.bulk_edit'), route('models.index')));+ ->breadcrumbs(fn (Trail $trail) => $trail->parent('models.index')+ ->push(trans('general.bulk_edit'), route('models.index')));Route::post('bulksave',[- BulkAssetModelsController::class,- 'update'+ BulkAssetModelsController::class,+ 'update',])->name('models.bulkedit.store');Route::post('bulkdelete',[- BulkAssetModelsController::class,- 'destroy'+ BulkAssetModelsController::class,+ 'destroy',])->name('models.bulkdelete.store');--});Route::resource('models', AssetModelsController::class, [diff --git a/routes/web/users.php b/routes/web/users.phpindex cfe66aeb4b..601896cd60 100644--- a/routes/web/users.php+++ b/routes/web/users.php@@ -11,67 +11,66 @@ Route::group(['prefix' => 'users', 'middleware' => ['auth']], function () {Route::get('ldap',[- Users\LDAPImportController::class,- 'create'+ Users\LDAPImportController::class,+ 'create',])->name('ldap/user')- ->breadcrumbs(fn (Trail $trail) =>- $trail->parent('users.index')+ ->breadcrumbs(fn (Trail $trail) => $trail->parent('users.index')->push(trans('general.ldap_user_sync'), route('ldap/user')));Route::post('ldap',[- Users\LDAPImportController::class,- 'store'+ Users\LDAPImportController::class,+ 'store',]);Route::get('export',[- Users\UsersController::class,- 'getExportUserCsv'+ Users\UsersController::class,+ 'getExportUserCsv',])->name('users.export');Route::get('{user}/clone',[- Users\UsersController::class,- 'getClone'+ Users\UsersController::class,+ 'getClone',])->name('users.clone.show')->withTrashed();Route::post('{user}/clone',[- Users\UsersController::class,- 'postCreate'+ Users\UsersController::class,+ 'postCreate',])->name('users.clone.store')->withTrashed();Route::post('{user}/restore',[- Users\UsersController::class,- 'getRestore'+ Users\UsersController::class,+ 'getRestore',])->name('users.restore.store')->withTrashed();Route::post('{userId}/password',[- Users\UsersController::class,- 'sendPasswordReset'+ Users\UsersController::class,+ 'sendPasswordReset',])->name('users.password');Route::get('{userId}/print',[- Users\UsersController::class,- 'printInventory'+ Users\UsersController::class,+ 'printInventory',])->name('users.print');@@ -79,48 +78,46 @@ Route::group(['prefix' => 'users', 'middleware' => ['auth']], function () {'{userId}/email',[Users\UsersController::class,- 'emailAssetList'+ 'emailAssetList',])->name('users.email');Route::post('bulkedit',[- Users\BulkUsersController::class,- 'edit'+ Users\BulkUsersController::class,+ 'edit',])->name('users/bulkedit')- ->breadcrumbs(fn (Trail $trail) =>- $trail->parent('users.index')+ ->breadcrumbs(fn (Trail $trail) => $trail->parent('users.index')->push(trans('general.bulk_checkin_delete'), route('users.index')));Route::post('merge',[Users\BulkUsersController::class,- 'merge'+ 'merge',])->name('users.merge.save');-Route::post('bulksave',[- Users\BulkUsersController::class,- 'destroy'+ Users\BulkUsersController::class,+ 'destroy',])->name('users/bulksave');Route::post('bulkeditsave',[- Users\BulkUsersController::class,- 'update'+ Users\BulkUsersController::class,+ 'update',])->name('users/bulkeditsave');});Route::resource('users', Users\UsersController::class, [- 'middleware' => ['auth']+ 'middleware' => ['auth'],])->withTrashed();diff --git a/server.php b/server.phpindex f65c7c444f..0d289eb0ed 100644--- a/server.php+++ b/server.php@@ -3,10 +3,8 @@/*** Laravel - A PHP Framework For Web Artisans*- * @package Laravel* @author Taylor Otwell <[email protected]>*/-$uri = urldecode(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));diff --git a/tests/Feature/Accessories/Api/StoreAccessoryTest.php b/tests/Feature/Accessories/Api/StoreAccessoryTest.phpindex 27409f0d87..ded0534b66 100644--- a/tests/Feature/Accessories/Api/StoreAccessoryTest.php+++ b/tests/Feature/Accessories/Api/StoreAccessoryTest.php@@ -43,7 +43,6 @@ class StoreAccessoryTest extends TestCase implements TestsFullMultipleCompaniesS'name' => 'My Awesome Accessory',]);}-public function test_can_store_accessory(){diff --git a/tests/Feature/Settings/ShowSetUpPageTest.php b/tests/Feature/Settings/ShowSetUpPageTest.phpindex 1c5a4cdee4..07f0cc026e 100644--- a/tests/Feature/Settings/ShowSetUpPageTest.php+++ b/tests/Feature/Settings/ShowSetUpPageTest.php@@ -7,12 +7,10 @@ use Illuminate\Database\Events\QueryExecuted;use Illuminate\Http\Client\ConnectionException;use Illuminate\Http\Client\Request;use Illuminate\Http\Client\Response;-use Illuminate\Log\Events\MessageLogged;use Illuminate\Support\Facades\DB;use Illuminate\Support\Facades\Event;use Illuminate\Support\Facades\File;use Illuminate\Support\Facades\Http;-use Illuminate\Support\Facades\Log;use Illuminate\Support\Facades\URL;use Illuminate\Testing\TestResponse;use PDOException;diff --git a/upgrade.php b/upgrade.phpindex ae24661a47..8186cf8aef 100644--- a/upgrade.php+++ b/upgrade.php@@ -4,18 +4,19 @@ $error_icon = "\e[91m✘\e[0m";$success_icon = "\e[92m√\e[0m";$info_icon = "\e[93mⓘ\e[0m";-(PHP_SAPI !== 'cli' || isset($_SERVER['HTTP_USER_AGENT'])) && die('Access denied.');+(PHP_SAPI !== 'cli' || isset($_SERVER['HTTP_USER_AGENT'])) && exit('Access denied.');// We define this because we can't reliably use file_get_contents because some// machines don't allow URL access via allow_url_fopen being set to off-function url_get_contents ($Url) {+function url_get_contents($Url)+{$results = file_get_contents($Url);if ($results) {return $results;}- print("file_get_contents() failed, trying curl instead.\n");- if (!function_exists('curl_init')){- die("cURL is not installed!\nThis is required for Snipe-IT as well as the upgrade script, so you will need to fix this before continuing.\nAborting upgrade...\n");+ echo "file_get_contents() failed, trying curl instead.\n";+ if (! function_exists('curl_init')) {+ exit("cURL is not installed!\nThis is required for Snipe-IT as well as the upgrade script, so you will need to fix this before continuing.\nAborting upgrade...\n");}$ch = curl_init();curl_setopt($ch, CURLOPT_URL, $Url);@@ -24,17 +25,19 @@ function url_get_contents ($Url) {// weird corporate environments.// See: https://github.com/curl/curl/commit/2d6333101a71129a6a802eb93f84a5ac89e34479// this will _probably_ only work if your libcurl has been linked to Schannel, the native Windows SSL implementation- if (PHP_OS == "WINNT" && defined("CURLOPT_SSL_OPTIONS") && defined("CURLSSLOPT_NATIVE_CA")) {+ if (PHP_OS == 'WINNT' && defined('CURLOPT_SSL_OPTIONS') && defined('CURLSSLOPT_NATIVE_CA')) {curl_setopt($ch, CURLOPT_SSL_OPTIONS, CURLSSLOPT_NATIVE_CA);}$output = curl_exec($ch);curl_close($ch);if ($output === false) {- print("\e[91mError retrieving PHP requirements!\e[39m\n");- print("Error was: " . curl_error($ch) . "\n");- print("Try enabling allow_url_fopen in php.ini, or fixing your curl/OpenSSL setup, or try rerunning with --skip-php-compatibility-checks");+ echo "\e[91mError retrieving PHP requirements!\e[39m\n";+ echo 'Error was: '.curl_error($ch)."\n";+ echo 'Try enabling allow_url_fopen in php.ini, or fixing your curl/OpenSSL setup, or try rerunning with --skip-php-compatibility-checks';+return '{}';}+return $output;}@@ -46,8 +49,8 @@ $no_interactive = false;$skip_backup = false;// Check for branch or other overrides-if ($argc > 1){- for ($arg=1; $arg<$argc; $arg++){+if ($argc > 1) {+ for ($arg = 1; $arg < $argc; $arg++) {switch ($argv[$arg]) {case '--skip-php-compatibility-checks':$skip_php_checks = true;@@ -62,7 +65,7 @@ if ($argc > 1){break;case '--no-interactive':$no_interactive = true;- putenv("COMPOSER_NO_INTERACTION=1"); //put composer in non-interactive mode aswell+ putenv('COMPOSER_NO_INTERACTION=1'); // put composer in non-interactive mode aswellbreak;default: // for legacy support from before we started using --branch$branch = $argv[$arg];@@ -86,79 +89,75 @@ echo "- run a backup \n";echo "- run migrations to get your schema up to date \n";echo "- clear out old cache settings\e[39m\n\n";-// Fetching most current upgrade requirements from github. Read more here: https://github.com/grokability/snipe-it/pull/14127$remote_requirements_file = "https://raw.githubusercontent.com/grokability/snipe-it/$branch/.upgrade_requirements.json";$upgrade_requirements_raw = url_get_contents($remote_requirements_file);$upgrade_requirements = json_decode($upgrade_requirements_raw, true);if (! $upgrade_requirements) {- if(!$skip_php_checks){+ if (! $skip_php_checks) {echo "\n\e[91mERROR: Failed to retrieve remote requirements from $remote_requirements_file \e[39m\n\n";- if ($branch_override){+ if ($branch_override) {echo "\e[93mNOTE: You passed a custom branch: $branch\n";echo "If the above URL doesn't work, that may be why. Please check the branch spelling/existence\e[39m\n\n";}if (json_last_error()) {- print "\e[91mJSON DECODE ERROR DETECTED:\n";- print json_last_error_msg() . "\n\n";- print "Raw curl output:\n";- print $upgrade_requirements_raw . "\e[39m\n\n";+ echo "\e[91mJSON DECODE ERROR DETECTED:\n";+ echo json_last_error_msg()."\n\n";+ echo "Raw curl output:\n";+ echo $upgrade_requirements_raw."\e[39m\n\n";}echo "\e[93mWe suggest correcting this, but if you can't, please verify that your requirements conform to those at that url.\n\n";echo "\e[91m-- DANGER -- DO AT YOUR OWN RISK --\n";echo "IF YOU ARE SURE, re-run this script with --skip-php-compatibility-checks to skip this check.\n";echo "-- DANGER -- THIS COULD BREAK YOUR INSTALLATION\e[39m\n\n";- die("Aborting upgrade.\n\n");+ exit("Aborting upgrade.\n\n");}echo "\e[93mNOTICE: Unable to fetch upgrade requirements, but continuing because you passed --skip-php-compatibility-checks...e[39m\n";}echo "Launching using branch: $branch\e[39m\n";-if($upgrade_requirements){+if ($upgrade_requirements) {$php_min_works = $upgrade_requirements['php_min_version'];$php_max_wontwork = $upgrade_requirements['php_max_wontwork'];echo "Found PHP requirements, will check for PHP > $php_min_works and < $php_max_wontwork\n";}// done fetching requirements-if (!$no_interactive) {+if (! $no_interactive) {$yesno = readline("\nProceed with upgrade? [y/N]: ");} else {- $yesno = "yes";+ $yesno = 'yes';}-if ($yesno == "yes" || $yesno == "YES" ||$yesno == "y" ||$yesno == "Y"){- # don't do anything+if ($yesno == 'yes' || $yesno == 'YES' || $yesno == 'y' || $yesno == 'Y') {+ // don't do anything} else {- die("Exiting.\n\n");+ exit("Exiting.\n\n");}echo "\n";-if ((strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') || (!function_exists('posix_getpwuid'))) {- echo "Skipping user check as it is not supported on Windows or Posix is not installed on this server. \n";+if ((strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') || (! function_exists('posix_getpwuid'))) {+ echo "Skipping user check as it is not supported on Windows or Posix is not installed on this server. \n";} else {- $pwu_data = posix_getpwuid(posix_geteuid());- $username = $pwu_data['name'];+ $pwu_data = posix_getpwuid(posix_geteuid());+ $username = $pwu_data['name'];- if (($username=='root') || ($username=='admin')) {- die("\n".$error_icon."ERROR: This script should not be run as root/admin. Exiting.\n\n");- }+ if (($username == 'root') || ($username == 'admin')) {+ exit("\n".$error_icon."ERROR: This script should not be run as root/admin. Exiting.\n\n");+ }}--echo "\e[95m--------------------------------------------------------\n";echo "STEP 1: Checking .env file: \n";echo "--------------------------------------------------------\e[39m\n\n";-// Check the .env looks ok$env = file('.env');-if (! $env){+if (! $env) {echo "\n\e[91m!!!!!!!!!!!!!!!!!!!!!!!!!! .ENV FILE ERROR !!!!!!!!!!!!!!!!!!!!!!!!!!\n";echo "Your .env file doesn't seem to exist in this directory or isn't readable! Please look into that.\n";exit(1);@@ -170,23 +169,22 @@ $env_bad = '';// Loop through each line of the .envforeach ($env as $line_num => $line) {- if ((strlen($line) > 1) && (strpos($line, "#") !== 0)) {+ if ((strlen($line) > 1) && (strpos($line, '#') !== 0)) {$env_line = explode('=', $line, 2);if (count($env_line) != 2) {continue;}- list ($env_key, $env_value) = $env_line;+ [$env_key, $env_value] = $env_line;// The array starts at 0- $show_line_num = $line_num+1;+ $show_line_num = $line_num + 1;$env_value = trim($env_value);// Strip out the quote marks if there are any- $env_value = str_replace('"', '',$env_value);- $env_value = str_replace("'", '',$env_value);-+ $env_value = str_replace('"', '', $env_value);+ $env_value = str_replace("'", '', $env_value);/*** We set this $app_environment here to determine which version of composer to use, --no-dev or with dev dependencies.@@ -199,16 +197,14 @@ foreach ($env as $line_num => $line) {** We use this further down in the composer section of this upgrader.*/-- if ($env_key == "APP_ENV") {+ if ($env_key == 'APP_ENV') {if ($env_value == 'production') {$app_environment = 'production';}}-if ($env_key == 'APP_KEY') {- if (($env_value=='') || (strlen($env_value) < 20)) {+ if (($env_value == '') || (strlen($env_value) < 20)) {$env_bad .= $error_icon." APP_KEY ERROR in your .env on line #'.{$show_line_num}.': Your APP_KEY should not be blank. Run `php artisan key:generate` to generate one.\n";} else {$env_good .= $success_icon." Your APP_KEY is not blank. \n";@@ -217,36 +213,34 @@ foreach ($env as $line_num => $line) {if ($env_key == 'APP_URL') {- if (($env_value!="null") && ($env_value!="")) {+ if (($env_value != 'null') && ($env_value != '')) {$env_good .= $success_icon.' Your APP_URL is not null or blank. It is set to '.$env_value."\n";- if (!str_begins(trim($env_value), 'http://') && (!str_begins($env_value, 'https://'))) {+ if (! str_begins(trim($env_value), 'http://') && (! str_begins($env_value, 'https://'))) {$env_bad .= $error_icon.' APP_URL ERROR in your .env on line #'.$show_line_num.': Your APP_URL should start with https:// or http://!! It is currently set to: '.$env_value;} else {$env_good .= $success_icon.' Your APP_URL is set to '.$env_value.' and starts with the protocol (https:// or http://)'."\n";}- if (str_ends(trim($env_value), "/")) {+ if (str_ends(trim($env_value), '/')) {$env_bad .= $error_icon.' APP_URL ERROR in your .env on line #'.$show_line_num.': Your APP_URL should NOT end with a trailing slash. It is currently set to: '.$env_value;} else {$env_good .= $success_icon.' Your APP_URL ('.$env_value.') does not have a trailing slash.'."\n";}-} else {- $env_bad .= $error_icon." APP_URL ERROR in your .env on line #".$show_line_num.": Your APP_URL CANNOT be set to null or left blank.\n";+ $env_bad .= $error_icon.' APP_URL ERROR in your .env on line #'.$show_line_num.": Your APP_URL CANNOT be set to null or left blank.\n";}}-}}echo $env_good;-if ($env_bad !='') {+if ($env_bad != '') {echo "\e[91m!!!!!!!!!!!!!!!!!!!!!!!!!! .ENV FILE ERROR !!!!!!!!!!!!!!!!!!!!!!!!!!\n";echo "\e[91mYour .env file is misconfigured. Upgrade cannot continue.\n";@@ -259,21 +253,20 @@ if ($env_bad !='') {exit(1);}--if(!$skip_php_checks){+if (! $skip_php_checks) {echo "\n\e[95m--------------------------------------------------------\n";- echo "STEP 2: Checking PHP requirements: (Required PHP >=". $php_min_works. " - <".$php_max_wontwork.")\n";+ echo 'STEP 2: Checking PHP requirements: (Required PHP >='.$php_min_works.' - <'.$php_max_wontwork.")\n";echo "--------------------------------------------------------\e[39m\n\n";if ((version_compare(phpversion(), $php_min_works, '>=')) && (version_compare(phpversion(), $php_max_wontwork, '<'))) {- echo $success_icon." Current PHP version: (" . phpversion() . ") is at least " . $php_min_works . " and less than ".$php_max_wontwork."! Continuing... \n";+ echo $success_icon.' Current PHP version: ('.phpversion().') is at least '.$php_min_works.' and less than '.$php_max_wontwork."! Continuing... \n";echo sprintf("FYI: The php.ini used by this PHP is: %s\n\n", get_cfg_var('cfg_file_path'));} else {echo "\e[91m!!!!!!!!!!!!!!!!!!!!!!!!! PHP VERSION ERROR !!!!!!!!!!!!!!!!!!!!!!!!!\n";- echo "This version of PHP (".phpversion().") is NOT compatible with Snipe-IT.\n";- echo "Snipe-IT requires PHP versions between ".$php_min_works." and ".$php_max_wontwork.".\n";+ echo 'This version of PHP ('.phpversion().") is NOT compatible with Snipe-IT.\n";+ echo 'Snipe-IT requires PHP versions between '.$php_min_works.' and '.$php_max_wontwork.".\n";echo "Please install a compatible version of PHP and re-run this script again. \n";echo "\e[91m!!!!!!!!!!!!!!!!!!!!!!!!! ABORTING THE UPGRADER !!!!!!!!!!!!!!!!!!!!!!\n";exit(1);@@ -306,7 +299,7 @@ $required_exts_array =$recommended_exts_array =[- 'sodium', //note that extensions need to be in BOTH the $required_exts_array and this one to be 'optional'+ 'sodium', // note that extensions need to be in BOTH the $required_exts_array and this one to be 'optional'];$ext_missing = '';$ext_installed = '';@@ -315,13 +308,13 @@ $ext_installed = '';foreach ($required_exts_array as $required_ext) {// If we don't find the string in the array....- if (!in_array($required_ext, $loaded_exts_array)) {+ if (! in_array($required_ext, $loaded_exts_array)) {// Let's check for any options with pipes in them - those mean you can have either orif (strpos($required_ext, '|')) {// Split the either/ors by their pipe and put them into an array- $require_either = explode("|", $required_ext);+ $require_either = explode('|', $required_ext);$has_one_required_ext = false;@@ -329,39 +322,39 @@ foreach ($required_exts_array as $required_ext) {foreach ($require_either as $require_either_value) {if (in_array($require_either_value, $loaded_exts_array)) {- $ext_installed .= $success_icon.' '.$require_either_value." is installed!\n";+ $ext_installed .= $success_icon.' '.$require_either_value." is installed!\n";$has_one_required_ext = true;break;}}// If no match, add it to the string for errors- if (!$has_one_required_ext) {- $ext_missing .= $error_icon.' MISSING PHP EXTENSION: '.str_replace("|", " OR ", $required_ext)."\n";+ if (! $has_one_required_ext) {+ $ext_missing .= $error_icon.' MISSING PHP EXTENSION: '.str_replace('|', ' OR ', $required_ext)."\n";break;}- // If this isn't an either/or option, just add it to the string of errors conventionally- } elseif (!in_array($required_ext, $recommended_exts_array)){- $ext_missing .= $error_icon.' MISSING PHP EXTENSION: '.$required_ext."\n";+ // If this isn't an either/or option, just add it to the string of errors conventionally+ } elseif (! in_array($required_ext, $recommended_exts_array)) {+ $ext_missing .= $error_icon.' MISSING PHP EXTENSION: '.$required_ext."\n";} else {$ext_installed .= '- '.$required_ext." is *NOT* installed, but is recommended...\n";}- // The required extension string was found in the array of installed extensions - yay!+ // The required extension string was found in the array of installed extensions - yay!} else {- $ext_installed .= $success_icon.' '.$required_ext." is installed!\n";+ $ext_installed .= $success_icon.' '.$required_ext." is installed!\n";}}// Print out a useful error message and abort the install-if ($ext_missing!='') {+if ($ext_missing != '') {echo "--------------------------------------------------------\n";echo "You have the following extensions installed: \n";echo "--------------------------------------------------------\n";foreach ($loaded_exts_array as $loaded_ext) {- echo $success_icon.' '.$loaded_ext."\n";+ echo $success_icon.' '.$loaded_ext."\n";}echo "\e[91m--------------------- !! ERROR !! ----------------------\n";@@ -376,13 +369,10 @@ if ($ext_missing!='') {}--echo "\e[95m--------------------------------------------------------\n";echo "STEP 3: Checking directory permissions: \n";echo "--------------------------------------------------------\e[39m\n\n";-$writable_dirs_array =['bootstrap/cache',@@ -415,7 +405,7 @@ foreach ($writable_dirs_array as $writable_dir) {echo $dirs_writable."\n";// Print out a useful error message-if ($dirs_not_writable!='') {+if ($dirs_not_writable != '') {echo "\e[91m--------------------------------------------------------\n";echo "\eThe following directories/files do not seem writable: \n";echo "\e--------------------------------------------------------\e[39m\n";@@ -428,11 +418,8 @@ if ($dirs_not_writable!='') {exit(1);}---echo "\e[95m--------------------------------------------------------\n";-echo "STEP 4: Pulling latest from Git (".$branch." branch): \n";+echo 'STEP 4: Pulling latest from Git ('.$branch." branch): \n";echo "--------------------------------------------------------\e[39m\n\n";$git_version = shell_exec('git --version');@@ -446,19 +433,19 @@ if ((strpos('git version', $git_version)) === false) {if (count($remote_bits) != 2) {continue;}- @list($url, $purpose) = explode(" ", $remote_bits[1]);+ @[$url, $purpose] = explode(' ', $remote_bits[1]);if (in_array($url, ['[email protected]:snipe/snipe-it.git', 'https://github.com/snipe/snipe-it.git'])) {// SSH or HTTPS remotes- $new_url = preg_replace("|snipe/snipe-it|", "grokability/snipe-it", $url);- echo $success_icon . " Resetting remote " . $remote_bits[0] . " at $url to $new_url for purpose: $purpose\n";+ $new_url = preg_replace('|snipe/snipe-it|', 'grokability/snipe-it', $url);+ echo $success_icon.' Resetting remote '.$remote_bits[0]." at $url to $new_url for purpose: $purpose\n";$push = '';if ($purpose == '(push)') {$push = '--push ';}- $cmd = "git remote set-url $push" . $remote_bits[0] . " " . $new_url;+ $cmd = "git remote set-url $push".$remote_bits[0].' '.$new_url;$remote_reset = shell_exec($cmd);if ($remote_reset) {- echo '-- ' . $remote_reset . "\n";+ echo '-- '.$remote_reset."\n";}}}@@ -481,7 +468,6 @@ if ((strpos('git version', $git_version)) === false) {}-echo "\e[95m--------------------------------------------------------\n";echo "STEP 5: Cleaning up old cached files:\n";echo "--------------------------------------------------------\e[39m\n\n";@@ -489,28 +475,27 @@ echo "--------------------------------------------------------\e[39m\n\n";// Build an array of the files we generally want to delete because they// can cause issues with funky caching$unused_files = [- "bootstrap/cache/compiled.php",- "bootstrap/cache/services.php",- "bootstrap/cache/config.php",- "vendor/symfony/translation/TranslatorInterface.php",+ 'bootstrap/cache/compiled.php',+ 'bootstrap/cache/services.php',+ 'bootstrap/cache/config.php',+ 'vendor/symfony/translation/TranslatorInterface.php',];foreach ($unused_files as $unused_file) {if (file_exists($unused_file)) {- echo $success_icon." Deleting ".$unused_file.". It is no longer used.\n";+ echo $success_icon.' Deleting '.$unused_file.". It is no longer used.\n";@unlink($unused_file);} else {- echo $success_icon." No ".$unused_file.", so nothing to delete.\n";+ echo $success_icon.' No '.$unused_file.", so nothing to delete.\n";}}echo "\n";-echo "\e[95m--------------------------------------------------------\n";echo "STEP 6: Updating composer dependencies:\n";echo "(This may take a moment.)\n";echo "--------------------------------------------------------\e[39m\n\n";-echo "-- Running the app in ".$app_environment." mode.\n";+echo '-- Running the app in '.$app_environment." mode.\n";// Composer installif (file_exists('composer.phar')) {@@ -544,7 +529,6 @@ if (file_exists('composer.phar')) {$composer_dump = shell_exec('composer dump');-}echo $composer_dump."\n";@@ -563,34 +547,30 @@ echo "\n";echo "\e[95m--------------------------------------------------------\n";echo "STEP 7: Putting application into maintenance mode: \n";echo "--------------------------------------------------------\e[39m\n\n";-exec('php artisan down', $down_results, $return_code);-echo '-- ' . implode("\n", $down_results) . "\n";+exec('php artisan down', $down_results, $return_code);+echo '-- '.implode("\n", $down_results)."\n";if ($return_code > 0) {- die("Something went wrong with downing your site. This can't be good. Please investigate the error and be sure to check https://snipe-it.readme.io/docs/common-issues and https://snipe-it.readme.io/docs/installation-issues for solutions to common upgrading issues. Aborting!\n\n");+ exit("Something went wrong with downing your site. This can't be good. Please investigate the error and be sure to check https://snipe-it.readme.io/docs/common-issues and https://snipe-it.readme.io/docs/installation-issues for solutions to common upgrading issues. Aborting!\n\n");}unset($return_code);-echo "\e[95m--------------------------------------------------------\n";echo "STEP 8: Backing up database: \n";echo "--------------------------------------------------------\e[39m\n\n";-if (!$skip_backup) {+if (! $skip_backup) {$backup = exec('php artisan snipeit:backup', $backup_results, $return_code);if ($return_code > 0) {- die($error_icon." Something went wrong with your backup. Aborting!\n\n");+ exit($error_icon." Something went wrong with your backup. Aborting!\n\n");} else {- echo '-- ' . implode("\n", $backup_results) . "\n\n";+ echo '-- '.implode("\n", $backup_results)."\n\n";}unset($return_code);} else {echo "Upgrade was run with --skip-backup, so no backup will be run.\n\n";}---echo "\e[95m--------------------------------------------------------\n";echo "STEP 9: Migrating database:\n";echo "--------------------------------------------------------\e[39m\n\n";@@ -598,13 +578,11 @@ echo "--------------------------------------------------------\e[39m\n\n";$migrations = shell_exec('php artisan migrate --force');echo $migrations."\n";-echo "\e[95m--------------------------------------------------------\n";echo "STEP 10: Checking for OAuth keys:\n";echo "--------------------------------------------------------\e[39m\n\n";--if ((!file_exists('storage/oauth-public.key')) || (!file_exists('storage/oauth-private.key'))) {+if ((! file_exists('storage/oauth-public.key')) || (! file_exists('storage/oauth-private.key'))) {echo $info_icon." No OAuth keys detected. Running passport install now.\n\n";$passport = shell_exec('php artisan passport:install --no-interaction');echo $passport;@@ -612,7 +590,6 @@ if ((!file_exists('storage/oauth-public.key')) || (!file_exists('storage/oauth-pecho $success_icon." OAuth keys detected. Skipping passport install.\n\n";}-echo "\e[95m--------------------------------------------------------\n";echo "STEP 11: Taking application out of maintenance mode:\n";echo "--------------------------------------------------------\e[39m\n\n";@@ -620,18 +597,17 @@ echo "--------------------------------------------------------\e[39m\n\n";$up = shell_exec('php artisan up');echo $success_icon.' '.trim($up)."\n\n";--echo "\e[92m---------------------- FINISHED! -----------------------\n";echo "All done! Clear your browser cookies and re-login to use \n";echo "your upgraded Snipe-IT!\n";echo "--------------------------------------------------------\e[39m\n\n";--function str_begins($haystack, $needle) {- return (substr_compare($haystack, $needle, 0, strlen($needle)) === 0);+function str_begins($haystack, $needle)+{+ return substr_compare($haystack, $needle, 0, strlen($needle)) === 0;}-function str_ends($haystack, $needle) {- return (substr_compare($haystack, $needle, -strlen($needle)) === 0);+function str_ends($haystack, $needle)+{+ return substr_compare($haystack, $needle, -strlen($needle)) === 0;}