- @if ($debug_in_production)
@@ -827,21 +826,68 @@ dir="{{ Helper::determineLanguageDirection() }}"> @endif -
-

@yield('title')

+
- @if (isset($helpText)) - @include ('partials.more-info', - [ - 'helpText' => $helpText, - 'helpPosition' => (isset($helpPosition)) ? $helpPosition : 'left' - ]) - @endif -
diff --git a/resources/views/partials/bootstrap-table.blade.php b/resources/views/partials/bootstrap-table.blade.php index 099640f0b..36ac4de50 100644 --- a/resources/views/partials/bootstrap-table.blade.php +++ b/resources/views/partials/bootstrap-table.blade.php @@ -290,9 +290,6 @@ var dest = 'admin/groups'; } - if (dest =='maintenances') { - var dest = 'hardware/maintenances'; - } if(element_name != '') { dest = dest + '/' + row.owner_id + '/' + element_name; diff --git a/resources/views/partials/more-info.blade.php b/resources/views/partials/more-info.blade.php index 370eb350d..1ba80c160 100644 --- a/resources/views/partials/more-info.blade.php +++ b/resources/views/partials/more-info.blade.php @@ -1,4 +1,4 @@ - - + + {{ trans('general.moreinfo') }} diff --git a/resources/views/reports/custom.blade.php b/resources/views/reports/custom.blade.php index 766d0beb9..e7802651b 100644 --- a/resources/views/reports/custom.blade.php +++ b/resources/views/reports/custom.blade.php @@ -33,7 +33,7 @@ @section('content')
-
+
@if (request()->routeIs('reports/custom') || request()->routeIs('report-templates.show')) -

+

{{ trans('general.customize_report') }}

+ @endif + @if (request()->routeIs('report-templates.edit'))
-
+
@endif - @if (request()->routeIs('report-templates.show')) -
- - - {{ trans('general.update') }} - - -
- @endif +
@@ -636,7 +616,7 @@
-
+
@if (! request()->routeIs('report-templates.edit'))
@@ -653,6 +633,41 @@ @endforeach
+ +
+
+ @if (request()->routeIs('report-templates.show')) + + + {{ trans('general.update') }} + + + + + + + {{ trans('general.delete') }} + + + + + + @endif +
+
@endif @if (request()->routeIs('reports/custom'))
diff --git a/resources/views/users/view.blade.php b/resources/views/users/view.blade.php index 0d53c7ad2..aee61a40a 100755 --- a/resources/views/users/view.blade.php +++ b/resources/views/users/view.blade.php @@ -863,7 +863,7 @@ @can('update', $license) - {{ trans('general.checkin') }} + {{ trans('general.checkin') }} @endcan diff --git a/routes/web.php b/routes/web.php index fac651dea..a3df05ac7 100644 --- a/routes/web.php +++ b/routes/web.php @@ -2,6 +2,9 @@ use App\Http\Controllers\Account; use App\Http\Controllers\ActionlogController; +use App\Http\Controllers\Auth\ForgotPasswordController; +use App\Http\Controllers\Auth\LoginController; +use App\Http\Controllers\Auth\ResetPasswordController; use App\Http\Controllers\CategoriesController; use App\Http\Controllers\CompaniesController; use App\Http\Controllers\DashboardController; @@ -9,25 +12,22 @@ use App\Http\Controllers\DepartmentsController; use App\Http\Controllers\DepreciationsController; use App\Http\Controllers\GroupsController; use App\Http\Controllers\HealthController; -use App\Http\Controllers\ImportsController; use App\Http\Controllers\LabelsController; use App\Http\Controllers\LocationsController; use App\Http\Controllers\ManufacturersController; use App\Http\Controllers\ModalController; use App\Http\Controllers\NotesController; use App\Http\Controllers\ProfileController; -use App\Http\Controllers\ReportsController; use App\Http\Controllers\ReportTemplatesController; +use App\Http\Controllers\ReportsController; use App\Http\Controllers\SettingsController; use App\Http\Controllers\StatuslabelsController; use App\Http\Controllers\SuppliersController; use App\Http\Controllers\ViewAssetsController; -use App\Http\Controllers\Auth\LoginController; -use App\Http\Controllers\Auth\ForgotPasswordController; -use App\Http\Controllers\Auth\ResetPasswordController; use App\Livewire\Importer; +use App\Models\ReportTemplate; use Illuminate\Support\Facades\Route; -use Illuminate\Support\Facades\Auth; +use Tabuna\Breadcrumbs\Trail; Route::group(['middleware' => 'auth'], function () { /* @@ -102,37 +102,27 @@ Route::group(['middleware' => 'auth'], function () { Route::post('{manufacturers_id}/restore', [ManufacturersController::class, 'restore'] )->name('restore/manufacturer'); }); - Route::resource('manufacturers', ManufacturersController::class, [ - 'parameters' => ['manufacturer' => 'manufacturers_id'], - ]); + Route::resource('manufacturers', ManufacturersController::class); /* * Suppliers */ - Route::resource('suppliers', SuppliersController::class, [ - 'parameters' => ['supplier' => 'supplier_id'], - ]); + Route::resource('suppliers', SuppliersController::class); /* * Depreciations */ - Route::resource('depreciations', DepreciationsController::class, [ - 'parameters' => ['depreciation' => 'depreciation_id'], - ]); + Route::resource('depreciations', DepreciationsController::class); /* * Status Labels */ - Route::resource('statuslabels', StatuslabelsController::class, [ - 'parameters' => ['statuslabel' => 'statuslabel_id'], - ]); + Route::resource('statuslabels', StatuslabelsController::class); /* * Departments */ - Route::resource('departments', DepartmentsController::class, [ - 'parameters' => ['department' => 'department_id'], - ]); + Route::resource('departments', DepartmentsController::class); }); /* @@ -179,46 +169,137 @@ Route::group(['middleware' => 'auth'], function () { */ Route::group(['prefix' => 'admin', 'middleware' => ['auth', 'authorize:superuser']], function () { - Route::get('settings', [SettingsController::class, 'getSettings'])->name('settings.general.index'); - Route::post('settings', [SettingsController::class, 'postSettings'])->name('settings.general.save'); - Route::get('branding', [SettingsController::class, 'getBranding'])->name('settings.branding.index'); - Route::post('branding', [SettingsController::class, 'postBranding'])->name('settings.branding.save'); + Route::get('settings', [SettingsController::class, 'getSettings']) + ->name('settings.general.index') + ->breadcrumbs(fn (Trail $trail) => + $trail->parent('settings.index') + ->push(trans('admin/settings/general.general_title'), route('settings.general.index'))); - Route::get('security', [SettingsController::class, 'getSecurity'])->name('settings.security.index'); - Route::post('security', [SettingsController::class, 'postSecurity'])->name('settings.security.save'); + Route::post('settings', [SettingsController::class, 'postSettings']) + ->name('settings.general.save'); - Route::get('groups', [GroupsController::class, 'index'])->name('settings.groups.index'); + Route::get('branding', [SettingsController::class, 'getBranding']) + ->name('settings.branding.index') + ->breadcrumbs(fn (Trail $trail) => + $trail->parent('settings.index') + ->push(trans('admin/settings/general.branding_title'), route('settings.branding.index'))); - Route::get('localization', [SettingsController::class, 'getLocalization'])->name('settings.localization.index'); - Route::post('localization', [SettingsController::class, 'postLocalization'])->name('settings.localization.save'); + Route::post('branding', [SettingsController::class, 'postBranding']) + ->name('settings.branding.save'); - Route::get('notifications', [SettingsController::class, 'getAlerts'])->name('settings.alerts.index'); - Route::post('notifications', [SettingsController::class, 'postAlerts'])->name('settings.alerts.save'); + Route::get('security', [SettingsController::class, 'getSecurity']) + ->name('settings.security.index') + ->breadcrumbs(fn (Trail $trail) => + $trail->parent('settings.index') + ->push(trans('admin/settings/general.security_title'), route('settings.security.index'))); - Route::get('slack', [SettingsController::class, 'getSlack'])->name('settings.slack.index'); - Route::post('slack', [SettingsController::class, 'postSlack'])->name('settings.slack.save'); + Route::post('security', [SettingsController::class, 'postSecurity']) + ->name('settings.security.save'); - Route::get('asset_tags', [SettingsController::class, 'getAssetTags'])->name('settings.asset_tags.index'); - Route::post('asset_tags', [SettingsController::class, 'postAssetTags'])->name('settings.asset_tags.save'); + Route::get('localization', [SettingsController::class, 'getLocalization']) + ->name('settings.localization.index') + ->breadcrumbs(fn (Trail $trail) => + $trail->parent('settings.index') + ->push(trans('admin/settings/general.localization_title'), route('settings.localization.index'))); - Route::get('labels', [SettingsController::class, 'getLabels'])->name('settings.labels.index'); - Route::post('labels', [SettingsController::class, 'postLabels'])->name('settings.labels.save'); + Route::post('localization', [SettingsController::class, 'postLocalization']) + ->name('settings.localization.save'); - Route::get('ldap', [SettingsController::class, 'getLdapSettings'])->name('settings.ldap.index'); - Route::post('ldap', [SettingsController::class, 'postLdapSettings'])->name('settings.ldap.save'); + Route::get('notifications', [SettingsController::class, 'getAlerts']) + ->name('settings.alerts.index') + ->breadcrumbs(fn (Trail $trail) => + $trail->parent('settings.index') + ->push(trans('admin/settings/general.alert_title'), route('settings.alerts.index'))); - Route::get('phpinfo', [SettingsController::class, 'getPhpInfo'])->name('settings.phpinfo.index'); + Route::post('notifications', [SettingsController::class, 'postAlerts']) + ->name('settings.alerts.save'); - Route::get('oauth', [SettingsController::class, 'api'])->name('settings.oauth.index'); + Route::get('slack', [SettingsController::class, 'getSlack']) + ->name('settings.slack.index') + ->breadcrumbs(fn (Trail $trail) => + $trail->parent('settings.index') + ->push(trans('admin/settings/general.webhook_title'), route('settings.slack.index'))); + + Route::post('slack', [SettingsController::class, 'postSlack']) + ->name('settings.slack.save'); + + Route::get('asset_tags', [SettingsController::class, 'getAssetTags']) + ->name('settings.asset_tags.index') + ->breadcrumbs(fn (Trail $trail) => + $trail->parent('settings.index') + ->push(trans('admin/settings/general.asset_tag_title'), route('settings.asset_tags.index'))); + + Route::post('asset_tags', [SettingsController::class, 'postAssetTags']) + ->name('settings.asset_tags.save'); + + Route::get('labels', [SettingsController::class, 'getLabels']) + ->name('settings.labels.index') + ->breadcrumbs(fn (Trail $trail) => + $trail->parent('settings.index') + ->push(trans('admin/settings/general.labels_title'), route('settings.labels.index'))); + + Route::post('labels', [SettingsController::class, 'postLabels']) + ->name('settings.labels.save'); + + Route::get('ldap', [SettingsController::class, 'getLdapSettings']) + ->name('settings.ldap.index') + ->breadcrumbs(fn (Trail $trail) => + $trail->parent('settings.index') + ->push(trans('admin/settings/general.ldap_ad'), route('settings.ldap.index'))); + + Route::post('ldap', [SettingsController::class, 'postLdapSettings']) + ->name('settings.ldap.save'); + + Route::get('phpinfo', [SettingsController::class, 'getPhpInfo']) + ->name('settings.phpinfo.index') + ->breadcrumbs(fn (Trail $trail) => + $trail->parent('settings.index') + ->push(trans('admin/settings/general.php_info'), route('settings.phpinfo.index'))); + + Route::get('oauth', [SettingsController::class, 'api']) + ->name('settings.oauth.index') + ->breadcrumbs(fn (Trail $trail) => + $trail->parent('settings.index') + ->push(trans('admin/settings/general.oauth'), route('settings.oauth.index'))); + + Route::get('google', [SettingsController::class, 'getGoogleLoginSettings']) + ->name('settings.google.index') + ->breadcrumbs(fn (Trail $trail) => + $trail->parent('settings.index') + ->push(trans('admin/settings/general.google_login'), route('settings.google.index'))); + + Route::post('google', [SettingsController::class, 'postGoogleLoginSettings']) + ->name('settings.google.save'); + + Route::get('purge', [SettingsController::class, 'getPurge']) + ->name('settings.purge.index') + ->breadcrumbs(fn (Trail $trail) => + $trail->parent('settings.index') + ->push(trans('admin/settings/general.purge'), route('settings.purge.index'))); + + Route::post('purge', [SettingsController::class, 'postPurge']) + ->name('settings.purge.save'); + + Route::get('login-attempts', [SettingsController::class, 'getLoginAttempts']) + ->name('settings.logins.index') + ->breadcrumbs(fn (Trail $trail) => + $trail->parent('settings.index') + ->push(trans('admin/settings/general.login'), route('settings.logins.index'))); + + + // SAML + Route::get('/saml', [SettingsController::class, 'getSamlSettings']) + ->name('settings.saml.index') + ->breadcrumbs(fn (Trail $trail) => + $trail->parent('settings.index') + ->push(trans('admin/settings/general.saml_title'), route('settings.saml.index'))); + + Route::post('/saml', [SettingsController::class, 'postSamlSettings']) + ->name('settings.saml.save'); - Route::get('google', [SettingsController::class, 'getGoogleLoginSettings'])->name('settings.google.index'); - Route::post('google', [SettingsController::class, 'postGoogleLoginSettings'])->name('settings.google.save'); - Route::get('purge', [SettingsController::class, 'getPurge'])->name('settings.purge.index'); - Route::post('purge', [SettingsController::class, 'postPurge'])->name('settings.purge.save'); - Route::get('login-attempts', [SettingsController::class, 'getLoginAttempts'])->name('settings.logins.index'); // Backups Route::group(['prefix' => 'backups', 'middleware' => 'auth'], function () { @@ -245,15 +326,25 @@ Route::group(['prefix' => 'admin', 'middleware' => ['auth', 'authorize:superuser return redirect(route('settings.backups.index')); }); - Route::get('/', [SettingsController::class, 'getBackups'])->name('settings.backups.index'); + Route::get('/', [SettingsController::class, 'getBackups']) + ->name('settings.backups.index') + ->breadcrumbs(fn (Trail $trail) => + $trail->parent('settings.index') + ->push(trans('admin/settings/general.backups'), route('settings.backups.index'))); }); - Route::resource('groups', GroupsController::class, [ - 'middleware' => ['auth'], - 'parameters' => ['group' => 'group_id'], - ]); + Route::resource('groups', GroupsController::class); - Route::get('/', [SettingsController::class, 'index'])->name('settings.index'); + + /** + * This breadcrumb is repeated for groups in the BreadcrumbServiceProvider, since groups uses resource routes + * and that servcie provider cannot see the breadcrumbs defined below + */ + Route::get('/', [SettingsController::class, 'index']) + ->name('settings.index') + ->breadcrumbs(fn (Trail $trail) => + $trail->parent('home') + ->push(trans('general.admin'), route('settings.index'))); }); /* @@ -265,9 +356,12 @@ Route::group(['prefix' => 'admin', 'middleware' => ['auth', 'authorize:superuser | */ -Route::get('/import', - Importer::class -)->middleware('auth')->name('imports.index'); +Route::get('/import', Importer::class) + ->middleware('auth') + ->name('imports.index') + ->breadcrumbs(fn (Trail $trail) => + $trail->parent('home') + ->push(trans('general.import'), route('imports.index'))); /* |-------------------------------------------------------------------------- @@ -280,26 +374,54 @@ Route::get('/import', Route::group(['prefix' => 'account', 'middleware' => ['auth']], function () { // Profile - Route::get('profile', [ProfileController::class, 'getIndex'])->name('profile'); - Route::post('profile', [ProfileController::class, 'postIndex'])->name('profile.update'); + Route::get('profile', [ProfileController::class, 'getIndex']) + ->name('profile') + ->breadcrumbs(fn (Trail $trail) => + $trail->parent('home') + ->push(trans('general.editprofile'), route('profile'))); - Route::get('menu', [ProfileController::class, 'getMenuState'])->name('account.menuprefs'); + Route::post('profile', [ProfileController::class, 'postIndex']) + ->name('profile.update'); - Route::get('password', [ProfileController::class, 'password'])->name('account.password.index'); - Route::post('password', [ProfileController::class, 'passwordSave'])->name('account.password.update'); + Route::get('menu', [ProfileController::class, 'getMenuState']) + ->name('account.menuprefs'); - Route::get('api', [ProfileController::class, 'api'])->name('user.api'); + Route::get('password', [ProfileController::class, 'password']) + ->name('account.password.index') + ->breadcrumbs(fn (Trail $trail) => + $trail->parent('home') + ->push(trans('general.changepassword'), route('account.password.index'))); + + Route::post('password', [ProfileController::class, 'passwordSave']) + ->name('account.password.update'); + + Route::get('api', [ProfileController::class, 'api']) + ->name('user.api') + ->breadcrumbs(fn (Trail $trail) => + $trail->parent('home') + ->push(trans('general.manage_api_keys'), route('user.api'))); // View Assets - Route::get('view-assets', [ViewAssetsController::class, 'getIndex'])->name('view-assets'); + Route::get('view-assets', [ViewAssetsController::class, 'getIndex']) + ->name('view-assets') + ->breadcrumbs(fn (Trail $trail) => + $trail->parent('home') + ->push(trans('general.viewassets'), route('view-assets'))); - Route::get('requested', [ViewAssetsController::class, 'getRequestedAssets'])->name('account.requested'); + Route::get('requested', [ViewAssetsController::class, 'getRequestedAssets']) + ->name('account.requested') + ->breadcrumbs(fn (Trail $trail) => + $trail->parent('home') + ->push(trans('general.requested_assets_menu'), route('account.requested'))); // Profile Route::get( - 'requestable-assets', - [ViewAssetsController::class, 'getRequestableIndex'] - )->name('requestable-assets'); + 'requestable-assets', [ViewAssetsController::class, 'getRequestableIndex']) + ->name('requestable-assets') + ->breadcrumbs(fn (Trail $trail) => + $trail->parent('home') + ->push(trans('general.requestable_items'), route('requestable-assets'))); + Route::post( 'request-asset/{assetId}', [ViewAssetsController::class, 'getRequestAsset'] @@ -311,13 +433,20 @@ Route::group(['prefix' => 'account', 'middleware' => ['auth']], function () { )->name('account/request-item'); // Account Dashboard - Route::get('/', [ViewAssetsController::class, 'getIndex'])->name('account'); + Route::get('/', [ViewAssetsController::class, 'getIndex']) + ->name('account'); Route::get('accept', [Account\AcceptanceController::class, 'index']) - ->name('account.accept'); + ->name('account.accept') + ->breadcrumbs(fn (Trail $trail) => + $trail->parent('home') + ->push(trans('general.accept_assets_menu'), route('account.accept'))); Route::get('accept/{id}', [Account\AcceptanceController::class, 'create']) - ->name('account.accept.item'); + ->name('account.accept.item') + ->breadcrumbs(fn (Trail $trail, $id) => + $trail->parent('account.accept') + ->push(trans('general.accept_item'), route('account.accept.item', $id))); Route::post('accept/{id}', [Account\AcceptanceController::class, 'store']) ->name('account.store-acceptance'); @@ -344,77 +473,128 @@ Route::group(['middleware' => ['auth']], function () { Route::post('notes', [NotesController::class, 'store'])->name('notes.store'); }); -Route::group(['middleware' => ['auth']], function () { - Route::get('reports/audit', - [ReportsController::class, 'audit'] - )->name('reports.audit'); +Route::group(['prefix' => 'reports', 'middleware' => ['auth']], function () { + + Route::get('audit', [ReportsController::class, 'audit']) + ->name('reports.audit') + ->breadcrumbs(fn (Trail $trail) => + $trail->parent('home') + ->push(trans('general.audit_report'), route('reports.audit'))); Route::get( - 'reports/depreciation', - [ReportsController::class, 'getDeprecationReport'] - )->name('reports/depreciation'); - Route::get( - 'reports/export/depreciation', - [ReportsController::class, 'exportDeprecationReport'] - )->name('reports/export/depreciation'); - Route::get( - 'reports/asset_maintenances', - [ReportsController::class, 'getAssetMaintenancesReport'] - )->name('reports/asset_maintenances'); - Route::get( - 'reports/export/asset_maintenances', - [ReportsController::class, 'exportAssetMaintenancesReport'] - )->name('reports/export/asset_maintenances'); - Route::get( - 'reports/licenses', - [ReportsController::class, 'getLicenseReport'] - )->name('reports/licenses'); - Route::get( - 'reports/export/licenses', - [ReportsController::class, 'exportLicenseReport'] - )->name('reports/export/licenses'); + 'depreciation', [ReportsController::class, 'getDeprecationReport']) + ->name('reports/depreciation') + ->breadcrumbs(fn (Trail $trail) => + $trail->parent('home') + ->push(trans('general.depreciation_report'), route('reports/depreciation'))); - Route::get('reports/accessories', [ReportsController::class, 'getAccessoryReport'])->name('reports/accessories'); - Route::get( - 'reports/export/accessories', - [ReportsController::class, 'exportAccessoryReport'] - )->name('reports/export/accessories'); - Route::get('reports/custom', [ReportsController::class, 'getCustomReport'])->name('reports/custom'); - Route::post('reports/custom', [ReportsController::class, 'postCustom']); - Route::prefix('reports/templates')->name('report-templates')->group(function () { - Route::post('/', [ReportTemplatesController::class, 'store'])->name('.store'); - Route::get('/{reportTemplate}', [ReportTemplatesController::class, 'show'])->name('.show'); - Route::get('/{reportTemplate}/edit', [ReportTemplatesController::class, 'edit'])->name('.edit'); - Route::post('/{reportTemplate}', [ReportTemplatesController::class, 'update'])->name('.update'); - Route::delete('/{reportTemplate}', [ReportTemplatesController::class, 'destroy'])->name('.destroy'); + // Is this still used?? + Route::get( + 'export/depreciation', [ReportsController::class, 'exportDeprecationReport']) + ->name('reports/export/depreciation') + ->breadcrumbs(fn (Trail $trail) => + $trail->parent('home') + ->push(trans('general.depreciation_report'), route('reports.audit'))); + + Route::get( + 'asset_maintenances', [ReportsController::class, 'getAssetMaintenancesReport']) + ->name('reports/asset_maintenances') + ->breadcrumbs(fn (Trail $trail) => + $trail->parent('home') + ->push(trans('general.asset_maintenance_report'), route('reports/asset_maintenances'))); + + // Is this still used? + Route::get('export/asset_maintenances', [ReportsController::class, 'exportAssetMaintenancesReport']) + ->name('reports/export/asset_maintenances') + ->breadcrumbs(fn (Trail $trail) => + $trail->parent('home') + ->push(trans('general.asset_maintenance_report'), route('reports/export/asset_maintenances'))); + + Route::get('licenses', [ReportsController::class, 'getLicenseReport']) + ->name('reports/licenses') + ->breadcrumbs(fn (Trail $trail) => + $trail->parent('home') + ->push(trans('general.license_report'), route('reports/licenses'))); + + Route::get('export/licenses', [ReportsController::class, 'exportLicenseReport']) + ->name('reports/export/licenses'); + + Route::get('accessories', [ReportsController::class, 'getAccessoryReport']) + ->name('reports/accessories'); + + Route::get('export/accessories', [ReportsController::class, 'exportAccessoryReport']) + ->name('reports/export/accessories'); + + Route::get('custom', [ReportsController::class, 'getCustomReport']) + ->name('reports/custom') + ->breadcrumbs(fn (Trail $trail) => + $trail->parent('home') + ->push(trans('general.custom_report'), route('reports/custom'))); + + Route::post('custom', [ReportsController::class, 'postCustom']); + + + Route::prefix('templates') + ->group(function () { + + Route::post('/', [ReportTemplatesController::class, 'store']) + ->name('report-templates.store'); + + // The breadcrumb on this is a little odd for now since we don't have a template index + Route::get('/{reportTemplate}', [ReportTemplatesController::class, 'show']) + ->name('report-templates.show') + ->breadcrumbs(fn (Trail $trail, ReportTemplate $reportTemplate) => + $trail->parent('reports/custom') + ->push($reportTemplate->name, null) + ->push(trans('general.customize_report'), '')); + + Route::get('/{reportTemplate}/edit', [ReportTemplatesController::class, 'edit']) + ->name('report-templates.edit') + ->breadcrumbs(fn (Trail $trail, ReportTemplate $reportTemplate) => + $trail->parent('reports/custom') + ->push($reportTemplate->name, route('report-templates.show', $reportTemplate)) + ->push(trans('general.customize_report'), '')); + + + Route::post('/{reportTemplate}', [ReportTemplatesController::class, 'update']) + ->name('report-templates.update'); + + Route::delete('/{reportTemplate}', [ReportTemplatesController::class, 'destroy']) + ->name('report-templates.destroy'); }); - Route::get( - 'reports/activity', - [ReportsController::class, 'getActivityReport'] - )->name('reports.activity'); - Route::post('reports/activity', [ReportsController::class, 'postActivityReport'])->name('reports.activity.post'); Route::get( - 'reports/unaccepted_assets/{deleted?}', - [ReportsController::class, 'getAssetAcceptanceReport'] - )->name('reports/unaccepted_assets'); + 'activity', [ReportsController::class, 'getActivityReport']) + ->name('reports.activity') + ->breadcrumbs(fn (Trail $trail) => + $trail->parent('home') + ->push(trans('general.activity_report'), route('reports.activity'))); + + Route::post('activity', [ReportsController::class, 'postActivityReport']) + ->name('reports.activity.post'); + + Route::get('unaccepted_assets/{deleted?}', [ReportsController::class, 'getAssetAcceptanceReport']) + ->name('reports/unaccepted_assets') + ->breadcrumbs(fn (Trail $trail) => + $trail->parent('home') + ->push(trans('general.unaccepted_asset_report'), route('reports/unaccepted_assets'))); + + Route::post('unaccepted_assets/sent_reminder', [ReportsController::class, 'sentAssetAcceptanceReminder']) + ->name('reports/unaccepted_assets_sent_reminder'); + + Route::delete('unaccepted_assets/{acceptanceId}/delete', [ReportsController::class, 'deleteAssetAcceptance']) + ->name('reports/unaccepted_assets_delete'); + Route::post( - 'reports/unaccepted_assets/sent_reminder', - [ReportsController::class, 'sentAssetAcceptanceReminder'] - )->name('reports/unaccepted_assets_sent_reminder'); - Route::delete( - 'reports/unaccepted_assets/{acceptanceId}/delete', - [ReportsController::class, 'deleteAssetAcceptance'] - )->name('reports/unaccepted_assets_delete'); - Route::post( - 'reports/unaccepted_assets/{deleted?}', - [ReportsController::class, 'postAssetAcceptanceReport'] - )->name('reports/export/unaccepted_assets'); + 'unaccepted_assets/{deleted?}', [ReportsController::class, 'postAssetAcceptanceReport']) + ->name('reports/export/unaccepted_assets'); + }); + Route::get( 'auth/signin', [LoginController::class, 'legacyAuthRedirect'] @@ -526,14 +706,6 @@ Route::group(['middleware' => 'web'], function () { Route::get('google/callback', 'App\Http\Controllers\GoogleAuthController@handleGoogleCallback')->name('google.callback'); - Route::get( - '/', - [ - 'as' => 'home', - 'middleware' => ['auth'], - 'uses' => 'DashboardController@getIndex' ] - ); - // need to keep GET /logout for SAML SLO Route::get( 'logout', @@ -559,4 +731,7 @@ Route::withoutMiddleware(['web'])->get( Route::middleware(['auth'])->get( '/', [DashboardController::class, 'index'] -)->name('home'); +)->name('home') + ->breadcrumbs(fn (Trail $trail) => + $trail->push('Home', route('home')) + ); diff --git a/routes/web/accessories.php b/routes/web/accessories.php index 1f28892a0..cf73e26e0 100644 --- a/routes/web/accessories.php +++ b/routes/web/accessories.php @@ -53,6 +53,5 @@ Route::group(['prefix' => 'accessories', 'middleware' => ['auth']], function () }); Route::resource('accessories', Accessories\AccessoriesController::class, [ - 'middleware' => ['auth'], - 'parameters' => ['accessory' => 'accessory_id'], + 'middleware' => ['auth'] ]); diff --git a/routes/web/fields.php b/routes/web/fields.php index cdd8fda5d..7500053c7 100644 --- a/routes/web/fields.php +++ b/routes/web/fields.php @@ -33,14 +33,17 @@ Route::group([ 'prefix' => 'fields','middleware' => ['auth'] ], function () { )->name('fieldsets.associate'); Route::resource('fieldsets', CustomFieldsetsController::class, [ - 'parameters' => ['fieldset' => 'field_id', 'field' => 'field_id'] + 'parameters' => [ + 'fieldset' => 'fieldset', + 'field' => 'field_id' + ] ]); }); -Route::resource('fields', CustomFieldsController::class, [ - 'middleware' => ['auth'], - 'parameters' => ['field' => 'field_id', 'fieldset' => 'fieldset_id'], -]); +Route::resource('fields', CustomFieldsController::class, + ['middleware' => ['auth'], + 'except' => ['show'] + ]); diff --git a/routes/web/hardware.php b/routes/web/hardware.php index ee888aa1d..3f858b120 100644 --- a/routes/web/hardware.php +++ b/routes/web/hardware.php @@ -6,7 +6,10 @@ use App\Http\Controllers\Assets\BulkAssetsController; use App\Http\Controllers\Assets\AssetCheckoutController; use App\Http\Controllers\Assets\AssetCheckinController; use App\Http\Controllers\Assets\AssetFilesController; +use App\Models\Setting; +use Tabuna\Breadcrumbs\Trail; use Illuminate\Support\Facades\Route; +use App\Models\Asset; /* |-------------------------------------------------------------------------- @@ -24,47 +27,59 @@ Route::group( function () { - Route::get('bulkaudit', - [AssetsController::class, 'quickScan'] - )->name('assets.bulkaudit'); + Route::get('bulkaudit', [AssetsController::class, 'quickScan']) + ->name('assets.bulkaudit') + ->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'); + Route::get('quickscancheckin', [AssetsController::class, 'quickScanCheckin']) + ->name('hardware/quickscancheckin') + ->breadcrumbs(fn (Trail $trail) => + $trail->parent('hardware.index') + ->push('Quickscan Checkin', route('hardware/quickscancheckin')) + ); - // Asset Maintenances - Route::resource('maintenances', - AssetMaintenancesController::class, [ - 'parameters' => ['maintenance' => 'maintenance_id', 'asset' => 'asset_id'], - ]); + Route::get('requested', [AssetsController::class, 'getRequestedIndex']) + ->name('assets.requested') + ->breadcrumbs(fn (Trail $trail) => + $trail->parent('hardware.index') + ->push(trans('admin/hardware/general.requested'), route('assets.requested')) + ); - Route::get('requested', [ - AssetsController::class, 'getRequestedIndex'] - )->name('assets.requested'); - - Route::get('scan', - [AssetsController::class, 'scan'] - )->name('asset.scan'); - - Route::get('audit/due', - [AssetsController::class, 'dueForAudit'] - )->name('assets.audit.due'); + Route::get('audit/due', [AssetsController::class, 'dueForAudit']) + ->name('assets.audit.due') + ->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'); + )->name('assets.checkins.due') + ->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('audit/{id}', - [AssetsController::class, 'audit'] - )->name('asset.audit.create'); + Route::get('audit/{asset}', [AssetsController::class, 'audit']) + ->name('asset.audit.create') + ->breadcrumbs(fn (Trail $trail, Asset $asset) => + $trail->parent('hardware.show', $asset) + ->push(trans('general.audit')) + ); - Route::post('audit/{id}', + Route::post('audit/{asset}', [AssetsController::class, 'auditStore'] )->name('asset.audit.store'); - Route::get('history', - [AssetsController::class, 'getImportHistory'] - )->name('asset.import-history'); + Route::get('history', [AssetsController::class, 'getImportHistory']) + ->name('asset.import-history') + ->breadcrumbs(fn (Trail $trail) => + $trail->parent('hardware.index') + ->push(trans('general.import-history'), route('asset.import-history')) + ); Route::post('history', [AssetsController::class, 'postImportHistory'] @@ -85,11 +100,12 @@ Route::group( Route::get('{assetId}/label', [AssetsController::class, 'getLabel'] )->name('label/hardware'); - - Route::get('{assetId}/checkout', - [AssetCheckoutController::class, 'create'] - )->name('hardware.checkout.create'); + Route::get('{asset}/checkout', [AssetCheckoutController::class, 'create'])->name('hardware.checkout.create') + ->breadcrumbs(fn (Trail $trail, Asset $asset) => + $trail->parent('hardware.show', $asset) + ->push(trans('admin/hardware/general.bulk_checkout'), route('hardware.index')) + ); Route::post('{assetId}/checkout', [AssetCheckoutController::class, 'store'] @@ -108,7 +124,7 @@ Route::group( return redirect()->route('hardware.show', ['hardware' => $assetId]); }); - Route::get('{assetId}/qr_code', + Route::get('{asset}/qr_code', [AssetsController::class, 'getQrCode'] )->name('qr_code/hardware'); @@ -153,9 +169,12 @@ Route::group( )->name('hardware/bulksave'); // Bulk checkout / checkin - Route::get('bulkcheckout', - [BulkAssetsController::class, 'showCheckout'] - )->name('hardware.bulkcheckout.show'); + Route::get('bulkcheckout', [BulkAssetsController::class, 'showCheckout']) + ->name('hardware.bulkcheckout.show') + ->breadcrumbs(fn (Trail $trail) => + $trail->parent('hardware.index') + ->push(trans('admin/hardware/general.bulk_checkout'), route('hardware.index')) + ); Route::post('bulkcheckout', [BulkAssetsController::class, 'storeCheckout'] @@ -163,16 +182,17 @@ Route::group( }); -Route::resource('hardware', - AssetsController::class, - [ - 'middleware' => ['auth'], - 'parameters' => ['asset' => 'asset_id', - 'names' => [ - 'show' => 'view', - ], - ], -]); +Route::resource('hardware', + AssetsController::class, + ['middleware' => ['auth'] +])->parameters(['hardware' => 'asset']); + + +// Asset Maintenances +Route::resource('maintenances', + AssetMaintenancesController::class, [ + 'parameters' => ['maintenance' => 'maintenance', 'asset' => 'asset_id'], + ]); Route::get('ht/{any?}', [AssetsController::class, 'getAssetByTag'] diff --git a/routes/web/kits.php b/routes/web/kits.php index 6b687f0bf..abd2d7526 100644 --- a/routes/web/kits.php +++ b/routes/web/kits.php @@ -1,21 +1,17 @@ ['auth'], - 'parameters' => ['kit' => 'kit_id'], -]); - -Route::group(['prefix' => 'kits/{kit_id}', 'middleware' => ['auth']], function () { +Route::group(['prefix' => 'kits/{kit}', 'middleware' => ['auth']], function () { // Route::get('licenses', // [Kits\PredefinedKitsController::class, 'indexLicenses'] // )->name('kits.licenses.index'); - Route::post('licenses', + Route::put('licenses', [Kits\PredefinedKitsController::class, 'storeLicense'] )->name('kits.licenses.store'); @@ -23,9 +19,11 @@ Route::group(['prefix' => 'kits/{kit_id}', 'middleware' => ['auth']], function ( [Kits\PredefinedKitsController::class, 'updateLicense'] )->name('kits.licenses.update'); - Route::get('licenses/{license_id}/edit', - [Kits\PredefinedKitsController::class, 'editLicense'] - )->name('kits.licenses.edit'); + Route::get('licenses/{license_id}/edit', [Kits\PredefinedKitsController::class, 'editLicense']) + ->name('kits.licenses.edit') + ->breadcrumbs(fn (Trail $trail) => + $trail->parent('settings.index') + ->push(trans('admin/settings/general.backups'), route('kits.licenses.edit'))); Route::delete('licenses/{license_id}', [Kits\PredefinedKitsController::class, 'detachLicense'] @@ -35,7 +33,7 @@ Route::group(['prefix' => 'kits/{kit_id}', 'middleware' => ['auth']], function ( Route::put('models/{model_id}', [Kits\PredefinedKitsController::class, 'updateModel'] - )/* ->parameters([2 => 'kit_id', 1 => 'model_id'])*/->name('kits.models.update'); + )->name('kits.models.update'); Route::get('models/{model_id}/edit', [Kits\PredefinedKitsController::class, 'editModel'] @@ -63,18 +61,24 @@ Route::group(['prefix' => 'kits/{kit_id}', 'middleware' => ['auth']], function ( [Kits\PredefinedKitsController::class, 'updateAccessory'] )/*->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'); + Route::get('accessories/{accessory_id}/edit', [Kits\PredefinedKitsController::class, 'editAccessory']) + ->name('kits.accessories.edit'); - Route::delete('accessories/{accessory_id}', - [Kits\PredefinedKitsController::class, 'detachAccessory'] - )->name('kits.accessories.detach'); - Route::get('checkout', - [Kits\CheckoutKitController::class, 'showCheckout'] - )->name('kits.checkout.show'); + Route::delete('accessories/{accessory_id}', [Kits\PredefinedKitsController::class, 'detachAccessory']) + ->name('kits.accessories.detach'); - Route::post('checkout', - [Kits\CheckoutKitController::class, 'store'] - )->name('kits.checkout.store'); + Route::get('checkout', [Kits\CheckoutKitController::class, 'showCheckout']) + ->name('kits.checkout.show') + ->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']) + ->name('kits.checkout.store'); }); // kits + +// Predefined Kit Management +Route::resource('kits', Kits\PredefinedKitsController::class, [ + 'middleware' => ['auth'], +]); + diff --git a/routes/web/licenses.php b/routes/web/licenses.php index 7212a4764..39762c95c 100644 --- a/routes/web/licenses.php +++ b/routes/web/licenses.php @@ -2,6 +2,9 @@ use App\Http\Controllers\Licenses; use Illuminate\Support\Facades\Route; +use App\Models\License; +use App\Models\LicenseSeat; +use Tabuna\Breadcrumbs\Trail; // Licenses Route::group(['prefix' => 'licenses', 'middleware' => ['auth']], function () { @@ -10,16 +13,25 @@ Route::group(['prefix' => 'licenses', 'middleware' => ['auth']], function () { Route::get('{licenseId}/freecheckout', [Licenses\LicensesController::class, 'getFreeLicense'] )->name('licenses.freecheckout'); - Route::get('{licenseId}/checkout/{seatId?}', - [Licenses\LicenseCheckoutController::class, 'create'] - )->name('licenses.checkout'); + + Route::get('{license}/checkout/{seatId?}', [Licenses\LicenseCheckoutController::class, 'create']) + ->name('licenses.checkout') + ->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. - Route::get('{licenseSeatId}/checkin/{backto?}', - [Licenses\LicenseCheckinController::class, 'create'] - )->name('licenses.checkin'); + + Route::get('{licenseSeat}/checkin/{backto?}', [Licenses\LicenseCheckinController::class, 'create']) + ->name('licenses.checkin') + ->breadcrumbs(fn (Trail $trail, LicenseSeat $licenseSeat) => + $trail->parent('licenses.show', $licenseSeat->license) + ->push(trans('general.checkin'), route('licenses.checkin', $licenseSeat)) + ); Route::post('{licenseId}/checkin/{backto?}', [Licenses\LicenseCheckinController::class, 'store'] @@ -59,5 +71,4 @@ Route::group(['prefix' => 'licenses', 'middleware' => ['auth']], function () { Route::resource('licenses', Licenses\LicensesController::class, [ 'middleware' => ['auth'], - 'parameters' => ['license' => 'license_id'], ]); diff --git a/routes/web/users.php b/routes/web/users.php index e6aaf644a..d3e3c02c9 100644 --- a/routes/web/users.php +++ b/routes/web/users.php @@ -151,6 +151,5 @@ Route::group(['prefix' => 'users', 'middleware' => ['auth']], function () { Route::resource('users', Users\UsersController::class, [ 'middleware' => ['auth'], - 'parameters' => ['user' => 'user_id'], 'except' => ['update'] ]); diff --git a/tests/Feature/Accessories/Ui/ShowAccessoryTest.php b/tests/Feature/Accessories/Ui/ShowAccessoryTest.php index f9f2e566c..288ec9a50 100644 --- a/tests/Feature/Accessories/Ui/ShowAccessoryTest.php +++ b/tests/Feature/Accessories/Ui/ShowAccessoryTest.php @@ -12,7 +12,7 @@ class ShowAccessoryTest extends TestCase public function testRequiresPermissionToViewAccessory() { $this->actingAs(User::factory()->create()) - ->get(route('accessories.show', Accessory::factory()->create()->id)) + ->get(route('accessories.show', Accessory::factory()->create())) ->assertForbidden(); } @@ -25,8 +25,8 @@ class ShowAccessoryTest extends TestCase $userForCompanyB = User::factory()->for($companyB)->viewAccessories()->create(); $this->actingAs($userForCompanyB) - ->get(route('accessories.show', $accessoryForCompanyA->id)) - ->assertForbidden(); + ->get(route('accessories.show', $accessoryForCompanyA)) + ->assertStatus(302); } public function testCanViewAccessory() @@ -34,7 +34,7 @@ class ShowAccessoryTest extends TestCase $accessory = Accessory::factory()->create(); $this->actingAs(User::factory()->viewAccessories()->create()) - ->get(route('accessories.show', $accessory->id)) + ->get(route('accessories.show', $accessory)) ->assertOk() ->assertViewIs('accessories.view') ->assertViewHas(['accessory' => $accessory]); @@ -43,7 +43,7 @@ class ShowAccessoryTest extends TestCase public function testPageRenders() { $this->actingAs(User::factory()->superuser()->create()) - ->get(route('accessories.show', Accessory::factory()->create()->id)) + ->get(route('accessories.show', Accessory::factory()->create())) ->assertOk(); } diff --git a/tests/Feature/Accessories/Ui/UpdateAccessoryTest.php b/tests/Feature/Accessories/Ui/UpdateAccessoryTest.php index 1c6fe8a49..8c482b4f1 100644 --- a/tests/Feature/Accessories/Ui/UpdateAccessoryTest.php +++ b/tests/Feature/Accessories/Ui/UpdateAccessoryTest.php @@ -16,7 +16,7 @@ class UpdateAccessoryTest extends TestCase public function testRequiresPermissionToSeeEditAccessoryPage() { $this->actingAs(User::factory()->create()) - ->get(route('accessories.edit', Accessory::factory()->create()->id)) + ->get(route('accessories.edit', Accessory::factory()->create())) ->assertForbidden(); } diff --git a/tests/Feature/AssetModels/Ui/ShowAssetModelsTest.php b/tests/Feature/AssetModels/Ui/ShowAssetModelsTest.php index 8b4104adc..739112f59 100644 --- a/tests/Feature/AssetModels/Ui/ShowAssetModelsTest.php +++ b/tests/Feature/AssetModels/Ui/ShowAssetModelsTest.php @@ -11,7 +11,7 @@ class ShowAssetModelsTest extends TestCase public function testPageRenders() { $this->actingAs(User::factory()->superuser()->create()) - ->get(route('models.show', AssetModel::factory()->create()->id)) + ->get(route('models.show', AssetModel::factory()->create())) ->assertOk(); } } diff --git a/tests/Feature/AssetModels/Ui/UpdateAssetModelsTest.php b/tests/Feature/AssetModels/Ui/UpdateAssetModelsTest.php index d0dbb2ffc..6fdd1bbcf 100644 --- a/tests/Feature/AssetModels/Ui/UpdateAssetModelsTest.php +++ b/tests/Feature/AssetModels/Ui/UpdateAssetModelsTest.php @@ -24,7 +24,7 @@ class UpdateAssetModelsTest extends TestCase public function testPageRenders() { $this->actingAs(User::factory()->superuser()->create()) - ->get(route('models.edit', AssetModel::factory()->create()->id)) + ->get(route('models.edit', AssetModel::factory()->create())) ->assertOk(); } @@ -55,15 +55,15 @@ class UpdateAssetModelsTest extends TestCase $this->assertTrue(AssetModel::where('name', 'Test Model')->exists()); $response = $this->actingAs(User::factory()->superuser()->create()) - ->from(route('models.edit', ['model' => $model->id])) - ->put(route('models.update', ['model' => $model]), [ + ->from(route('models.edit', $model)) + ->put(route('models.update', $model), [ 'name' => 'Test Model Edited', 'category_id' => Category::factory()->forAccessories()->create()->id, ]) ->assertSessionHasErrors(['category_type']) ->assertInvalid(['category_type']) ->assertStatus(302) - ->assertRedirect(route('models.edit', ['model' => $model->id])); + ->assertRedirect(route('models.edit', $model)); $this->followRedirects($response)->assertSee(trans('general.error')); $this->assertFalse(AssetModel::where('name', 'Test Model Edited')->exists()); diff --git a/tests/Feature/Assets/Ui/EditAssetTest.php b/tests/Feature/Assets/Ui/EditAssetTest.php index 27f00b531..328067e89 100644 --- a/tests/Feature/Assets/Ui/EditAssetTest.php +++ b/tests/Feature/Assets/Ui/EditAssetTest.php @@ -27,7 +27,7 @@ class EditAssetTest extends TestCase { $asset = Asset::factory()->create(); $user = User::factory()->editAssets()->create(); - $response = $this->actingAs($user)->get(route('hardware.edit', $asset->id)); + $response = $this->actingAs($user)->get(route('hardware.edit', $asset)); $response->assertStatus(200); } @@ -63,7 +63,7 @@ class EditAssetTest extends TestCase 'model_id' => AssetModel::factory()->create()->id, ]) ->assertStatus(302) - ->assertRedirect(route('hardware.show', ['hardware' => $asset->id])); + ->assertRedirect(route('hardware.show', $asset)); $this->assertDatabaseHas('assets', ['asset_tag' => 'New Asset Tag']); } @@ -81,8 +81,8 @@ class EditAssetTest extends TestCase $currentTimestamp = now(); $this->actingAs(User::factory()->viewAssets()->editAssets()->create()) - ->from(route('hardware.edit', $asset->id)) - ->put(route('hardware.update', $asset->id), [ + ->from(route('hardware.edit', $asset)) + ->put(route('hardware.update', $asset), [ 'status_id' => $achived_status->id, 'model_id' => $asset->model_id, 'asset_tags' => $asset->asset_tag, diff --git a/tests/Feature/Categories/Ui/ShowCategoryTest.php b/tests/Feature/Categories/Ui/ShowCategoryTest.php index dd22b1d75..93a9cc0af 100644 --- a/tests/Feature/Categories/Ui/ShowCategoryTest.php +++ b/tests/Feature/Categories/Ui/ShowCategoryTest.php @@ -11,7 +11,7 @@ class ShowCategoryTest extends TestCase public function testPageRenders() { $this->actingAs(User::factory()->superuser()->create()) - ->get(route('categories.show', Category::factory()->create()->id)) + ->get(route('categories.show', Category::factory()->create())) ->assertOk(); } } diff --git a/tests/Feature/Categories/Ui/UpdateCategoriesTest.php b/tests/Feature/Categories/Ui/UpdateCategoriesTest.php index 7e6109779..ea5cc6338 100644 --- a/tests/Feature/Categories/Ui/UpdateCategoriesTest.php +++ b/tests/Feature/Categories/Ui/UpdateCategoriesTest.php @@ -23,7 +23,7 @@ class UpdateCategoriesTest extends TestCase public function testPageRenders() { $this->actingAs(User::factory()->superuser()->create()) - ->get(route('categories.edit', Category::factory()->create()->id)) + ->get(route('categories.edit', Category::factory()->create())) ->assertOk(); } @@ -47,7 +47,7 @@ class UpdateCategoriesTest extends TestCase $this->assertTrue(Category::where('name', 'Test Category')->exists()); $response = $this->actingAs(User::factory()->superuser()->create()) - ->put(route('categories.update', ['category' => $category]), [ + ->put(route('categories.update', $category), [ 'name' => 'Test Category Edited', 'notes' => 'Test Note Edited', ]) @@ -66,8 +66,8 @@ class UpdateCategoriesTest extends TestCase $this->assertTrue(Category::where('name', 'Test Category')->exists()); $response = $this->actingAs(User::factory()->superuser()->create()) - ->from(route('categories.edit', ['category' => $category->id])) - ->put(route('categories.update', ['category' => $category]), [ + ->from(route('categories.edit', $category->id)) + ->put(route('categories.update', $category), [ 'name' => 'Test Category Edited', 'category_type' => 'accessory', 'notes' => 'Test Note Edited', @@ -87,8 +87,8 @@ class UpdateCategoriesTest extends TestCase $category = Category::where('name', 'Laptops')->first(); $response = $this->actingAs(User::factory()->superuser()->create()) - ->from(route('categories.edit', ['category' => $category->id])) - ->put(route('categories.update', ['category' => $category]), [ + ->from(route('categories.edit', $category)) + ->put(route('categories.update', $category), [ 'name' => 'Test Category Edited', 'category_type' => 'accessory', 'notes' => 'Test Note Edited', @@ -96,7 +96,7 @@ class UpdateCategoriesTest extends TestCase ->assertSessionHasErrors(['category_type']) ->assertInvalid(['category_type']) ->assertStatus(302) - ->assertRedirect(route('categories.edit', ['category' => $category->id])); + ->assertRedirect(route('categories.edit', $category)); $this->followRedirects($response)->assertSee(trans('general.error')); $this->assertFalse(Category::where('name', 'Test Category Edited')->where('notes', 'Test Note Edited')->exists()); diff --git a/tests/Feature/Checkins/Ui/AssetCheckinTest.php b/tests/Feature/Checkins/Ui/AssetCheckinTest.php index 7428b7ab7..58194dbfc 100644 --- a/tests/Feature/Checkins/Ui/AssetCheckinTest.php +++ b/tests/Feature/Checkins/Ui/AssetCheckinTest.php @@ -188,7 +188,7 @@ class AssetCheckinTest extends TestCase ->get(route('hardware.checkin.create', ['assetId' => $asset->id])) ->assertStatus(302) ->assertSessionHas('error') - ->assertRedirect(route('hardware.show',['hardware' => $asset->id])); + ->assertRedirect(route('hardware.show', $asset->id)); } public function testAssetCheckinPagePostIsRedirectedIfModelIsInvalid() @@ -201,7 +201,7 @@ class AssetCheckinTest extends TestCase ->post(route('hardware.checkin.store', ['assetId' => $asset->id])) ->assertStatus(302) ->assertSessionHas('error') - ->assertRedirect(route('hardware.show', ['hardware' => $asset->id])); + ->assertRedirect(route('hardware.show', $asset)); } public function testAssetCheckinPagePostIsRedirectedIfRedirectSelectionIsIndex() @@ -228,6 +228,6 @@ class AssetCheckinTest extends TestCase ]) ->assertStatus(302) ->assertSessionHasNoErrors() - ->assertRedirect(route('hardware.show', ['hardware' => $asset->id])); + ->assertRedirect(route('hardware.show', $asset)); } } diff --git a/tests/Feature/Checkins/Ui/ComponentCheckinTest.php b/tests/Feature/Checkins/Ui/ComponentCheckinTest.php index 6c2ef084f..7da3879ea 100644 --- a/tests/Feature/Checkins/Ui/ComponentCheckinTest.php +++ b/tests/Feature/Checkins/Ui/ComponentCheckinTest.php @@ -16,9 +16,7 @@ class ComponentCheckinTest extends TestCase $componentAsset = DB::table('components_assets')->where('component_id', $component->id)->first(); $this->actingAs(User::factory()->create()) - ->post(route('components.checkin.store', [ - 'componentID' => $componentAsset->id, - ])) + ->post(route('components.checkin.store', $componentAsset->id)) ->assertForbidden(); } @@ -67,6 +65,6 @@ class ComponentCheckinTest extends TestCase ]) ->assertStatus(302) ->assertSessionHasNoErrors() - ->assertRedirect(route('components.show', ['component' => $component->id])); + ->assertRedirect(route('components.show', $component)); } } diff --git a/tests/Feature/Checkouts/Ui/AccessoryCheckoutTest.php b/tests/Feature/Checkouts/Ui/AccessoryCheckoutTest.php index ff121bc4d..19b0d1ce7 100644 --- a/tests/Feature/Checkouts/Ui/AccessoryCheckoutTest.php +++ b/tests/Feature/Checkouts/Ui/AccessoryCheckoutTest.php @@ -25,7 +25,7 @@ class AccessoryCheckoutTest extends TestCase public function testPageRenders() { $this->actingAs(User::factory()->superuser()->create()) - ->get(route('accessories.checkout.show', Accessory::factory()->create()->id)) + ->get(route('accessories.checkout.show', Accessory::factory()->create())) ->assertOk(); } @@ -241,7 +241,7 @@ class AccessoryCheckoutTest extends TestCase ]) ->assertStatus(302) ->assertSessionHasNoErrors() - ->assertRedirect(route('accessories.show', ['accessory' => $accessory->id])); + ->assertRedirect(route('accessories.show', $accessory)); } public function testAccessoryCheckoutPagePostIsRedirectedIfRedirectSelectionIsTarget() @@ -258,6 +258,6 @@ class AccessoryCheckoutTest extends TestCase 'assigned_qty' => 1, ]) ->assertStatus(302) - ->assertRedirect(route('users.show', ['user' => $user])); + ->assertRedirect(route('users.show', $user)); } } diff --git a/tests/Feature/Checkouts/Ui/AssetCheckoutTest.php b/tests/Feature/Checkouts/Ui/AssetCheckoutTest.php index 74658a6fa..f364064a1 100644 --- a/tests/Feature/Checkouts/Ui/AssetCheckoutTest.php +++ b/tests/Feature/Checkouts/Ui/AssetCheckoutTest.php @@ -260,10 +260,10 @@ class AssetCheckoutTest extends TestCase $asset->forceSave(); $this->actingAs(User::factory()->admin()->create()) - ->get(route('hardware.checkout.create', ['assetId' => $asset->id])) + ->get(route('hardware.checkout.create', $asset)) ->assertStatus(302) ->assertSessionHas('error') - ->assertRedirect(route('hardware.show',['hardware' => $asset->id])); + ->assertRedirect(route('hardware.show', $asset)); } public function testAssetCheckoutPagePostIsRedirectedIfRedirectSelectionIsIndex() @@ -294,7 +294,7 @@ class AssetCheckoutTest extends TestCase ]) ->assertStatus(302) ->assertSessionHasNoErrors() - ->assertRedirect(route('hardware.show', ['hardware' => $asset->id])); + ->assertRedirect(route('hardware.show', $asset)); } public function testAssetCheckoutPagePostIsRedirectedIfRedirectSelectionIsUserTarget() @@ -328,7 +328,7 @@ class AssetCheckoutTest extends TestCase 'assigned_qty' => 1, ]) ->assertStatus(302) - ->assertRedirect(route('hardware.show', ['hardware' => $target])); + ->assertRedirect(route('hardware.show', $target)); } public function testAssetCheckoutPagePostIsRedirectedIfRedirectSelectionIsLocationTarget() diff --git a/tests/Feature/Checkouts/Ui/ComponentsCheckoutTest.php b/tests/Feature/Checkouts/Ui/ComponentsCheckoutTest.php index 507b26243..18568d198 100644 --- a/tests/Feature/Checkouts/Ui/ComponentsCheckoutTest.php +++ b/tests/Feature/Checkouts/Ui/ComponentsCheckoutTest.php @@ -76,7 +76,7 @@ class ComponentsCheckoutTest extends TestCase 'assigned_qty' => 1, ]) ->assertStatus(302) - ->assertRedirect(route('components.show', ['component' => $component->id])); + ->assertRedirect(route('components.show', $component)); } public function testComponentCheckoutPagePostIsRedirectedIfRedirectSelectionIsTarget() @@ -92,6 +92,6 @@ class ComponentsCheckoutTest extends TestCase 'assigned_qty' => 1, ]) ->assertStatus(302) - ->assertRedirect(route('hardware.show', ['hardware' => $asset])); + ->assertRedirect(route('hardware.show', $asset)); } } diff --git a/tests/Feature/Checkouts/Ui/ConsumableCheckoutTest.php b/tests/Feature/Checkouts/Ui/ConsumableCheckoutTest.php index dd77e19c5..2c74e4d0c 100644 --- a/tests/Feature/Checkouts/Ui/ConsumableCheckoutTest.php +++ b/tests/Feature/Checkouts/Ui/ConsumableCheckoutTest.php @@ -130,7 +130,7 @@ class ConsumableCheckoutTest extends TestCase 'assigned_qty' => 1, ]) ->assertStatus(302) - ->assertRedirect(route('consumables.show', ['consumable' => $consumable->id])); + ->assertRedirect(route('consumables.show', $consumable)); } public function testConsumableCheckoutPagePostIsRedirectedIfRedirectSelectionIsTarget() @@ -146,7 +146,7 @@ class ConsumableCheckoutTest extends TestCase 'assigned_qty' => 1, ]) ->assertStatus(302) - ->assertRedirect(route('users.show', ['user' => $user])); + ->assertRedirect(route('users.show', $user)); } } diff --git a/tests/Feature/Checkouts/Ui/LicenseCheckoutTest.php b/tests/Feature/Checkouts/Ui/LicenseCheckoutTest.php index 22bdb6b5d..1750b7564 100644 --- a/tests/Feature/Checkouts/Ui/LicenseCheckoutTest.php +++ b/tests/Feature/Checkouts/Ui/LicenseCheckoutTest.php @@ -24,7 +24,7 @@ class LicenseCheckoutTest extends TestCase $licenseSeat = LicenseSeat::factory()->create(); $this->actingAs($admin) - ->post("/licenses/{$licenseSeat->license->id}/checkout", [ + ->post(route('licenses.checkout', $licenseSeat->license), [ 'checkout_to_type' => 'asset', 'assigned_to' => null, 'asset_id' => $asset->id, @@ -47,7 +47,7 @@ class LicenseCheckoutTest extends TestCase $licenseSeat = LicenseSeat::factory()->create(); $this->actingAs($admin) - ->post("/licenses/{$licenseSeat->license->id}/checkout", [ + ->post(route('licenses.checkout', $licenseSeat->license), [ 'checkout_to_type' => 'user', 'assigned_to' => $admin->id, 'asset_id' => null, @@ -69,8 +69,8 @@ class LicenseCheckoutTest extends TestCase $license = License::factory()->create(); $this->actingAs(User::factory()->admin()->create()) - ->from(route('licenses.checkout', ['licenseId' => $license->id])) - ->post(route('licenses.checkout', ['licenseId' => $license->id]), [ + ->from(route('licenses.checkout', $license)) + ->post(route('licenses.checkout', $license), [ 'assigned_to' => User::factory()->create()->id, 'redirect_option' => 'index', 'assigned_qty' => 1, @@ -84,13 +84,13 @@ class LicenseCheckoutTest extends TestCase $license = License::factory()->create(); $this->actingAs(User::factory()->admin()->create()) - ->from(route('licenses.checkout', ['licenseId' => $license->id])) - ->post(route('licenses.checkout' , ['licenseId' => $license->id]), [ + ->from(route('licenses.checkout', $license)) + ->post(route('licenses.checkout', $license), [ 'assigned_to' => User::factory()->create()->id, 'redirect_option' => 'item', ]) ->assertStatus(302) - ->assertRedirect(route('licenses.show', ['license' => $license->id])); + ->assertRedirect(route('licenses.show', $license)); } public function testLicenseCheckoutPagePostIsRedirectedIfRedirectSelectionIsUserTarget() @@ -99,13 +99,13 @@ class LicenseCheckoutTest extends TestCase $license = License::factory()->create(); $this->actingAs(User::factory()->admin()->create()) - ->from(route('licenses.checkout', ['licenseId' => $license->id])) + ->from(route('licenses.checkout', $license)) ->post(route('licenses.checkout' , $license), [ 'assigned_to' => $user->id, 'redirect_option' => 'target', ]) ->assertStatus(302) - ->assertRedirect(route('users.show', ['user' => $user->id])); + ->assertRedirect(route('users.show', $user)); } public function testLicenseCheckoutPagePostIsRedirectedIfRedirectSelectionIsAssetTarget() { @@ -113,12 +113,12 @@ class LicenseCheckoutTest extends TestCase $license = License::factory()->create(); $this->actingAs(User::factory()->admin()->create()) - ->from(route('licenses.checkout', ['licenseId' => $license->id])) + ->from(route('licenses.checkout', $license)) ->post(route('licenses.checkout' , $license), [ 'asset_id' => $asset->id, 'redirect_option' => 'target', ]) ->assertStatus(302) - ->assertRedirect(route('hardware.show', ['hardware' => $asset->id])); + ->assertRedirect(route('hardware.show', $asset)); } } diff --git a/tests/Feature/Companies/Ui/EditCompanyTest.php b/tests/Feature/Companies/Ui/EditCompanyTest.php index 7dcbc7908..febc71704 100644 --- a/tests/Feature/Companies/Ui/EditCompanyTest.php +++ b/tests/Feature/Companies/Ui/EditCompanyTest.php @@ -11,7 +11,7 @@ class EditCompanyTest extends TestCase public function testPageRenders() { $this->actingAs(User::factory()->superuser()->create()) - ->get(route('companies.edit', Company::factory()->create()->id)) + ->get(route('companies.edit', Company::factory()->create())) ->assertOk(); } } diff --git a/tests/Feature/Companies/Ui/ShowCompanyTest.php b/tests/Feature/Companies/Ui/ShowCompanyTest.php index 1c41f6ab2..de7429d40 100644 --- a/tests/Feature/Companies/Ui/ShowCompanyTest.php +++ b/tests/Feature/Companies/Ui/ShowCompanyTest.php @@ -11,7 +11,7 @@ class ShowCompanyTest extends TestCase public function testPageRenders() { $this->actingAs(User::factory()->superuser()->create()) - ->get(route('companies.show', Company::factory()->create()->id)) + ->get(route('companies.show', Company::factory()->create())) ->assertOk(); } } diff --git a/tests/Feature/Components/Ui/EditComponentTest.php b/tests/Feature/Components/Ui/EditComponentTest.php index 257034390..4e4b99233 100644 --- a/tests/Feature/Components/Ui/EditComponentTest.php +++ b/tests/Feature/Components/Ui/EditComponentTest.php @@ -11,7 +11,7 @@ class EditComponentTest extends TestCase public function testPageRenders() { $this->actingAs(User::factory()->superuser()->create()) - ->get(route('components.edit', Component::factory()->create()->id)) + ->get(route('components.edit', Component::factory()->create())) ->assertOk(); } } diff --git a/tests/Feature/Components/Ui/ShowComponentTest.php b/tests/Feature/Components/Ui/ShowComponentTest.php index 50a17ee05..6ee2ca286 100644 --- a/tests/Feature/Components/Ui/ShowComponentTest.php +++ b/tests/Feature/Components/Ui/ShowComponentTest.php @@ -11,7 +11,7 @@ class ShowComponentTest extends TestCase public function testPageRenders() { $this->actingAs(User::factory()->superuser()->create()) - ->get(route('components.show', Component::factory()->create()->id)) + ->get(route('components.show', Component::factory()->create())) ->assertOk(); } } diff --git a/tests/Feature/Consumables/Ui/EditConsumableTest.php b/tests/Feature/Consumables/Ui/EditConsumableTest.php index 6b75db127..308b7647b 100644 --- a/tests/Feature/Consumables/Ui/EditConsumableTest.php +++ b/tests/Feature/Consumables/Ui/EditConsumableTest.php @@ -11,7 +11,7 @@ class EditConsumableTest extends TestCase public function testPageRenders() { $this->actingAs(User::factory()->superuser()->create()) - ->get(route('consumables.show', Consumable::factory()->create()->id)) + ->get(route('consumables.show', Consumable::factory()->create())) ->assertOk(); } } diff --git a/tests/Feature/Consumables/Ui/UpdateConsumableTest.php b/tests/Feature/Consumables/Ui/UpdateConsumableTest.php index 66fc9a11f..dbb13b9ce 100644 --- a/tests/Feature/Consumables/Ui/UpdateConsumableTest.php +++ b/tests/Feature/Consumables/Ui/UpdateConsumableTest.php @@ -29,7 +29,7 @@ class UpdateConsumableTest extends TestCase $userForCompanyB = User::factory()->editConsumables()->for($companyB)->create(); $this->actingAs($userForCompanyB) - ->get(route('consumables.edit', $consumableForCompanyA->id)) + ->get(route('consumables.edit', $consumableForCompanyA)) ->assertRedirect(route('consumables.index')); } @@ -51,10 +51,10 @@ class UpdateConsumableTest extends TestCase $userForCompanyB = User::factory()->editConsumables()->for($companyB)->create(); $this->actingAs($userForCompanyB) - ->put(route('consumables.update', $consumableForCompanyA->id), [ + ->put(route('consumables.update', $consumableForCompanyA), [ // ]) - ->assertForbidden(); + ->assertStatus(302); } public function testCannotSetQuantityToAmountLowerThanWhatIsCheckedOut() @@ -99,7 +99,7 @@ class UpdateConsumableTest extends TestCase ]; $this->actingAs(User::factory()->createConsumables()->editConsumables()->create()) - ->put(route('consumables.update', $consumable->id), $data + [ + ->put(route('consumables.update', $consumable), $data + [ 'redirect_option' => 'index', 'category_type' => 'consumable', ]) diff --git a/tests/Feature/Departments/Ui/ShowDepartmentTest.php b/tests/Feature/Departments/Ui/ShowDepartmentTest.php index d8a007bde..f1373ccc2 100644 --- a/tests/Feature/Departments/Ui/ShowDepartmentTest.php +++ b/tests/Feature/Departments/Ui/ShowDepartmentTest.php @@ -11,7 +11,7 @@ class ShowDepartmentTest extends TestCase public function testPageRenders() { $this->actingAs(User::factory()->superuser()->create()) - ->get(route('departments.show', Department::factory()->create()->id)) + ->get(route('departments.show', Department::factory()->create())) ->assertOk(); } } diff --git a/tests/Feature/Departments/Ui/UpdateDepartmentsTest.php b/tests/Feature/Departments/Ui/UpdateDepartmentsTest.php index bb5fc27e1..83e52bf7c 100644 --- a/tests/Feature/Departments/Ui/UpdateDepartmentsTest.php +++ b/tests/Feature/Departments/Ui/UpdateDepartmentsTest.php @@ -22,7 +22,7 @@ class UpdateDepartmentsTest extends TestCase public function testPageRenders() { $this->actingAs(User::factory()->superuser()->create()) - ->get(route('departments.edit', Department::factory()->create()->id)) + ->get(route('departments.edit', Department::factory()->create())) ->assertOk(); } @@ -32,7 +32,7 @@ class UpdateDepartmentsTest extends TestCase $this->assertTrue(Department::where('name', 'Test Department')->exists()); $response = $this->actingAs(User::factory()->superuser()->create()) - ->put(route('departments.update', ['department' => $department]), [ + ->put(route('departments.update', $department), [ 'name' => 'Test Department Edited', 'notes' => 'Test Note Edited', ]) diff --git a/tests/Feature/Locations/Ui/ShowLocationTest.php b/tests/Feature/Locations/Ui/ShowLocationTest.php index 6afb7dfe5..394ed73f4 100644 --- a/tests/Feature/Locations/Ui/ShowLocationTest.php +++ b/tests/Feature/Locations/Ui/ShowLocationTest.php @@ -11,7 +11,7 @@ class ShowLocationTest extends TestCase public function testPageRenders() { $this->actingAs(User::factory()->superuser()->create()) - ->get(route('locations.show', Location::factory()->create()->id)) + ->get(route('locations.show', Location::factory()->create())) ->assertOk(); } } diff --git a/tests/Feature/Locations/Ui/UpdateLocationsTest.php b/tests/Feature/Locations/Ui/UpdateLocationsTest.php index c38ee25f8..3135e9bcf 100644 --- a/tests/Feature/Locations/Ui/UpdateLocationsTest.php +++ b/tests/Feature/Locations/Ui/UpdateLocationsTest.php @@ -21,7 +21,7 @@ class UpdateLocationsTest extends TestCase public function testPageRenders() { $this->actingAs(User::factory()->superuser()->create()) - ->get(route('locations.update', Location::factory()->create()->id)) + ->get(route('locations.update', Location::factory()->create())) ->assertOk(); } @@ -48,8 +48,8 @@ class UpdateLocationsTest extends TestCase $location = Location::factory()->create(); $response = $this->actingAs(User::factory()->superuser()->create()) - ->from(route('locations.edit', ['location' => $location->id])) - ->put(route('locations.update', ['location' => $location]), [ + ->from(route('locations.edit', $location)) + ->put(route('locations.update', $location), [ 'name' => 'Test Location', 'parent_id' => $location->id, ]) @@ -63,7 +63,7 @@ class UpdateLocationsTest extends TestCase { $location = Location::factory()->create(); $response = $this->actingAs(User::factory()->superuser()->create()) - ->from(route('locations.edit', ['location' => $location->id])) + ->from(route('locations.edit', $location)) ->put(route('locations.update', ['location' => $location]), [ 'name' => 'Test Location', 'parent_id' => '100000000' diff --git a/tests/Feature/Manufacturers/Ui/ShowManufacturerTest.php b/tests/Feature/Manufacturers/Ui/ShowManufacturerTest.php index 890feb123..9a40819a1 100644 --- a/tests/Feature/Manufacturers/Ui/ShowManufacturerTest.php +++ b/tests/Feature/Manufacturers/Ui/ShowManufacturerTest.php @@ -11,7 +11,7 @@ class ShowManufacturerTest extends TestCase public function testPageRenders() { $this->actingAs(User::factory()->superuser()->create()) - ->get(route('manufacturers.show', Manufacturer::factory()->create()->id)) + ->get(route('manufacturers.show', Manufacturer::factory()->create())) ->assertOk(); } } diff --git a/tests/Feature/Manufacturers/Ui/UpdateManufacturerTest.php b/tests/Feature/Manufacturers/Ui/UpdateManufacturerTest.php index 398b7fe23..9d5861300 100644 --- a/tests/Feature/Manufacturers/Ui/UpdateManufacturerTest.php +++ b/tests/Feature/Manufacturers/Ui/UpdateManufacturerTest.php @@ -11,7 +11,7 @@ class UpdateManufacturerTest extends TestCase public function testPageRenders() { $this->actingAs(User::factory()->superuser()->create()) - ->get(route('manufacturers.edit', Manufacturer::factory()->create()->id)) + ->get(route('manufacturers.edit', Manufacturer::factory()->create())) ->assertOk(); } @@ -21,7 +21,7 @@ class UpdateManufacturerTest extends TestCase $this->assertTrue(Manufacturer::where('name', 'Test Manufacturer')->exists()); $response = $this->actingAs(User::factory()->superuser()->create()) - ->put(route('manufacturers.update', ['manufacturer' => $manufacturer]), [ + ->put(route('manufacturers.update', $manufacturer), [ 'name' => 'Test Manufacturer Edited', 'notes' => 'Test Note Edited', ]) diff --git a/tests/Feature/ReportTemplates/DeleteReportTemplateTest.php b/tests/Feature/ReportTemplates/DeleteReportTemplateTest.php index 2b108443a..cebc8156a 100644 --- a/tests/Feature/ReportTemplates/DeleteReportTemplateTest.php +++ b/tests/Feature/ReportTemplates/DeleteReportTemplateTest.php @@ -17,7 +17,7 @@ class DeleteReportTemplateTest extends TestCase implements TestsPermissionsRequi $this->actingAs(User::factory()->create()) ->post(route('report-templates.destroy', $reportTemplate->id)) - ->assertNotFound(); + ->assertStatus(302); $this->assertModelExists($reportTemplate); } @@ -28,7 +28,7 @@ class DeleteReportTemplateTest extends TestCase implements TestsPermissionsRequi $this->actingAs(User::factory()->canViewReports()->create()) ->delete(route('report-templates.destroy', $reportTemplate->id)) - ->assertNotFound(); + ->assertStatus(302); $this->assertModelExists($reportTemplate); } diff --git a/tests/Feature/ReportTemplates/EditReportTemplateTest.php b/tests/Feature/ReportTemplates/EditReportTemplateTest.php index 88363ec8b..d359baddd 100644 --- a/tests/Feature/ReportTemplates/EditReportTemplateTest.php +++ b/tests/Feature/ReportTemplates/EditReportTemplateTest.php @@ -15,7 +15,7 @@ class EditReportTemplateTest extends TestCase implements TestsPermissionsRequire { $this->actingAs(User::factory()->create()) ->get(route('report-templates.edit', ReportTemplate::factory()->create())) - ->assertNotFound(); + ->assertStatus(302); } public function testCannotLoadEditPageForAnotherUsersReportTemplate() @@ -25,7 +25,7 @@ class EditReportTemplateTest extends TestCase implements TestsPermissionsRequire $this->actingAs($user) ->get(route('report-templates.edit', $reportTemplate)) - ->assertNotFound(); + ->assertStatus(302); } public function testCanLoadEditReportTemplatePage() diff --git a/tests/Feature/ReportTemplates/ShowReportTemplateTest.php b/tests/Feature/ReportTemplates/ShowReportTemplateTest.php index 3e57db898..748df288b 100644 --- a/tests/Feature/ReportTemplates/ShowReportTemplateTest.php +++ b/tests/Feature/ReportTemplates/ShowReportTemplateTest.php @@ -15,7 +15,7 @@ class ShowReportTemplateTest extends TestCase implements TestsPermissionsRequire { $this->actingAs(User::factory()->create()) ->get(route('report-templates.show', ReportTemplate::factory()->create())) - ->assertNotFound(); + ->assertStatus(302); } public function testCanLoadASavedReportTemplate() @@ -38,6 +38,6 @@ class ShowReportTemplateTest extends TestCase implements TestsPermissionsRequire $this->actingAs(User::factory()->canViewReports()->create()) ->get(route('report-templates.show', $reportTemplate)) - ->assertNotFound(); + ->assertStatus(302); } } diff --git a/tests/Feature/ReportTemplates/UpdateReportTemplateTest.php b/tests/Feature/ReportTemplates/UpdateReportTemplateTest.php index 9afecb084..09c168b27 100644 --- a/tests/Feature/ReportTemplates/UpdateReportTemplateTest.php +++ b/tests/Feature/ReportTemplates/UpdateReportTemplateTest.php @@ -15,14 +15,14 @@ class UpdateReportTemplateTest extends TestCase implements TestsPermissionsRequi { $this->actingAs(User::factory()->create()) ->post(route('report-templates.update', ReportTemplate::factory()->create())) - ->assertNotFound(); + ->assertStatus(302); } public function testCannotUpdateAnotherUsersReportTemplate() { $this->actingAs(User::factory()->canViewReports()->create()) ->post(route('report-templates.update', ReportTemplate::factory()->create())) - ->assertNotFound(); + ->assertStatus(302); } public function testUpdatingReportTemplateRequiresValidFields() diff --git a/tests/Feature/StatusLabels/Ui/ShowStatusLabelTest.php b/tests/Feature/StatusLabels/Ui/ShowStatusLabelTest.php index 0b7389603..96e8d7552 100644 --- a/tests/Feature/StatusLabels/Ui/ShowStatusLabelTest.php +++ b/tests/Feature/StatusLabels/Ui/ShowStatusLabelTest.php @@ -11,7 +11,7 @@ class ShowStatusLabelTest extends TestCase public function testPageRenders() { $this->actingAs(User::factory()->superuser()->create()) - ->get(route('statuslabels.show', Statuslabel::factory()->create()->id)) + ->get(route('statuslabels.show', Statuslabel::factory()->create())) ->assertOk(); } } diff --git a/tests/Feature/Users/Api/DeleteUsersTest.php b/tests/Feature/Users/Api/DeleteUsersTest.php index 9677e5f7d..a2e43f04b 100644 --- a/tests/Feature/Users/Api/DeleteUsersTest.php +++ b/tests/Feature/Users/Api/DeleteUsersTest.php @@ -37,7 +37,7 @@ class DeleteUsersTest extends TestCase implements TestsFullMultipleCompaniesSupp { $user = User::factory()->deletedUser()->create(); $this->actingAsForApi(User::factory()->deleteUsers()->create()) - ->deleteJson(route('api.users.destroy', $user->id)) + ->deleteJson(route('api.users.destroy', $user)) ->assertOk() ->assertStatus(200) ->assertStatusMessageIs('error') @@ -51,7 +51,7 @@ class DeleteUsersTest extends TestCase implements TestsFullMultipleCompaniesSupp $this->assertFalse($manager->isDeletable()); $this->actingAsForApi(User::factory()->deleteUsers()->create()) - ->deleteJson(route('api.users.destroy', $manager->id)) + ->deleteJson(route('api.users.destroy', $manager)) ->assertOk() ->assertStatus(200) ->assertStatusMessageIs('error') @@ -66,7 +66,7 @@ class DeleteUsersTest extends TestCase implements TestsFullMultipleCompaniesSupp $this->assertFalse($manager->isDeletable()); $this->actingAsForApi(User::factory()->deleteUsers()->create()) - ->deleteJson(route('api.users.destroy', $manager->id)) + ->deleteJson(route('api.users.destroy', $manager)) ->assertOk() ->assertStatus(200) ->assertStatusMessageIs('error') @@ -81,7 +81,7 @@ class DeleteUsersTest extends TestCase implements TestsFullMultipleCompaniesSupp $this->assertFalse($manager->isDeletable()); $this->actingAsForApi(User::factory()->deleteUsers()->create()) - ->deleteJson(route('api.users.destroy', $manager->id)) + ->deleteJson(route('api.users.destroy', $manager)) ->assertOk() ->assertStatus(200) ->assertStatusMessageIs('error') @@ -111,7 +111,7 @@ class DeleteUsersTest extends TestCase implements TestsFullMultipleCompaniesSupp $userFromB = User::factory()->deleteUsers()->for($companyB)->create(); $this->actingAsForApi($userFromA) - ->deleteJson(route('api.users.destroy', ['user' => $userFromB->id])) + ->deleteJson(route('api.users.destroy', $userFromB)) ->assertOk() ->assertStatus(200) ->assertStatusMessageIs('error') @@ -121,7 +121,7 @@ class DeleteUsersTest extends TestCase implements TestsFullMultipleCompaniesSupp $this->assertNull($userFromB->deleted_at); $this->actingAsForApi($userFromB) - ->deleteJson(route('api.users.destroy', ['user' => $userFromA->id])) + ->deleteJson(route('api.users.destroy', $userFromA)) ->assertOk() ->assertStatus(200) ->assertStatusMessageIs('error') @@ -131,7 +131,7 @@ class DeleteUsersTest extends TestCase implements TestsFullMultipleCompaniesSupp $this->assertNull($userFromA->deleted_at); $this->actingAsForApi($superuser) - ->deleteJson(route('api.users.destroy', ['user' => $userFromA->id])) + ->deleteJson(route('api.users.destroy', $userFromA)) ->assertOk() ->assertStatus(200) ->assertStatusMessageIs('success') diff --git a/tests/Feature/Users/Ui/ViewUserTest.php b/tests/Feature/Users/Ui/ViewUserTest.php index 791c80489..cb21a1e9e 100644 --- a/tests/Feature/Users/Ui/ViewUserTest.php +++ b/tests/Feature/Users/Ui/ViewUserTest.php @@ -20,11 +20,11 @@ class ViewUserTest extends TestCase $user = User::factory()->for($companyB)->create(); $this->actingAs(User::factory()->editUsers()->for($companyA)->create()) - ->get(route('users.show', ['user' => $user->id])) - ->assertStatus(403); + ->get(route('users.show', $user)) + ->assertStatus(302); $this->actingAs($superuser) - ->get(route('users.show', ['user' => $user->id])) + ->get(route('users.show', $user)) ->assertOk() ->assertStatus(200); }