-
+
@if (($asset->image) || (($asset->model) && ($asset->model->image!='')))
@@ -334,7 +334,7 @@
-
@@ -1120,7 +1121,7 @@
@else
-
+
{{ trans('general.no_results') }}
@@ -1157,7 +1158,7 @@
{{ Helper::formatCurrencyOutput($component->purchase_cost) }} each |
{{ $component->serial }} |
- {{ trans('general.checkin') }}
+ {{ trans('general.checkin') }}
|
purchase_cost *$component->pivot->assigned_qty) ?>
@@ -1175,7 +1176,7 @@
@else
-
+
{{ trans('general.no_results') }}
@@ -1239,7 +1240,7 @@
@else
-
+
{{ trans('general.no_results') }}
@@ -1399,11 +1400,11 @@
@if (($file->filename) && (Storage::exists('private_uploads/assets/'.$file->filename)))
-
+
-
+
@endif
@@ -1415,7 +1416,7 @@
|
@can('update', \App\Models\Asset::class)
-
+
@endcan
@@ -1427,7 +1428,7 @@
@else
-
+
{{ trans('general.no_results') }}
@@ -1503,12 +1504,12 @@
|
@if (($file->filename) && (Storage::exists('private_uploads/assetmodels/'.$file->filename)))
-
-
+
+
-
-
+
+
@endif
@@ -1520,8 +1521,8 @@
|
@can('update', \App\Models\AssetModel::class)
-
-
+
+
@endcan
|
diff --git a/resources/views/partials/forms/edit/address.blade.php b/resources/views/partials/forms/edit/address.blade.php
index c68ecaa8c2..893bd01339 100644
--- a/resources/views/partials/forms/edit/address.blade.php
+++ b/resources/views/partials/forms/edit/address.blade.php
@@ -35,6 +35,7 @@
{{ Form::label('country', trans('general.country'), array('class' => 'col-md-3 control-label')) }}
{!! Form::countries('country', old('country', $item->country), 'select2') !!}
+
{{ trans('general.countries_manually_entered_help') }}
{!! $errors->first('country', '
:message') !!}
diff --git a/resources/views/users/edit.blade.php b/resources/views/users/edit.blade.php
index 5f0246d022..1c23b76823 100755
--- a/resources/views/users/edit.blade.php
+++ b/resources/views/users/edit.blade.php
@@ -451,6 +451,8 @@
{!! Form::countries('country', old('country', $user->country), 'col-md-12 select2') !!}
+
+
{{ trans('general.countries_manually_entered_help') }}
{!! $errors->first('country', '
:message') !!}
diff --git a/resources/views/users/view.blade.php b/resources/views/users/view.blade.php
index 8fbed865ee..13924dd70c 100755
--- a/resources/views/users/view.blade.php
+++ b/resources/views/users/view.blade.php
@@ -159,9 +159,9 @@
@endif
-
+
-
+
@@ -197,7 +197,9 @@
{{ trans('admin/users/general.print_assigned') }}
@else
-
+
@endif
@endcan
@@ -306,7 +308,7 @@
-
+
@@ -765,6 +767,7 @@
@endif
+
diff --git a/routes/api.php b/routes/api.php
index 0eb0d834cf..35e6c92060 100644
--- a/routes/api.php
+++ b/routes/api.php
@@ -798,6 +798,33 @@ Route::group(['prefix' => 'v1', 'middleware' => ['api', 'throttle:api']], functi
]
)->name('api.models.restore');
+ Route::post('{model_id}/files',
+ [
+ Api\AssetModelFilesController::class,
+ 'store'
+ ]
+ )->name('api.models.files.store');
+
+ Route::get('{model_id}/files',
+ [
+ Api\AssetModelFilesController::class,
+ 'list'
+ ]
+ )->name('api.models.files.index');
+
+ Route::get('{model_id}/file/{file_id}',
+ [
+ Api\AssetModelFilesController::class,
+ 'show'
+ ]
+ )->name('api.models.files.show');
+
+ Route::delete('{model_id}/file/{file_id}',
+ [
+ Api\AssetModelFilesController::class,
+ 'destroy'
+ ]
+ )->name('api.models.files.destroy');
});
Route::resource('models',
diff --git a/tests/Feature/AssetModels/Api/AssetModelFilesTest.php b/tests/Feature/AssetModels/Api/AssetModelFilesTest.php
new file mode 100644
index 0000000000..c22609c0c7
--- /dev/null
+++ b/tests/Feature/AssetModels/Api/AssetModelFilesTest.php
@@ -0,0 +1,120 @@
+count(1)->create();
+
+ // Create a superuser to run this as
+ $user = User::factory()->superuser()->create();
+
+ //Upload a file
+ $this->actingAsForApi($user)
+ ->post(
+ route('api.models.files.store', ['model_id' => $model[0]["id"]]), [
+ 'file' => [UploadedFile::fake()->create("test.jpg", 100)]
+ ])
+ ->assertOk();
+ }
+
+ public function testAssetModelApiListsFiles()
+ {
+ // List all files on a model
+
+ // Create an model to work with
+ $model = AssetModel::factory()->count(1)->create();
+
+ // Create a superuser to run this as
+ $user = User::factory()->superuser()->create();
+
+ // List the files
+ $this->actingAsForApi($user)
+ ->getJson(
+ route('api.models.files.index', ['model_id' => $model[0]["id"]]))
+ ->assertOk()
+ ->assertJsonStructure([
+ 'status',
+ 'messages',
+ 'payload',
+ ]);
+ }
+
+ public function testAssetModelApiDownloadsFile()
+ {
+ // Download a file from a model
+
+ // Create a model to work with
+ $model = AssetModel::factory()->count(1)->create();
+
+ // Create a superuser to run this as
+ $user = User::factory()->superuser()->create();
+
+ //Upload a file
+ $this->actingAsForApi($user)
+ ->post(
+ route('api.models.files.store', ['model_id' => $model[0]["id"]]), [
+ 'file' => [UploadedFile::fake()->create("test.jpg", 100)]
+ ])
+ ->assertOk();
+
+ // List the files to get the file ID
+ $result = $this->actingAsForApi($user)
+ ->getJson(
+ route('api.models.files.index', ['model_id' => $model[0]["id"]]))
+ ->assertOk();
+
+ // Get the file
+ $this->actingAsForApi($user)
+ ->get(
+ route('api.models.files.show', [
+ 'model_id' => $model[0]["id"],
+ 'file_id' => $result->decodeResponseJson()->json()["payload"][0]["id"],
+ ]))
+ ->assertOk();
+ }
+
+ public function testAssetModelApiDeletesFile()
+ {
+ // Delete a file from a model
+
+ // Create a model to work with
+ $model = AssetModel::factory()->count(1)->create();
+
+ // Create a superuser to run this as
+ $user = User::factory()->superuser()->create();
+
+ //Upload a file
+ $this->actingAsForApi($user)
+ ->post(
+ route('api.models.files.store', ['model_id' => $model[0]["id"]]), [
+ 'file' => [UploadedFile::fake()->create("test.jpg", 100)]
+ ])
+ ->assertOk();
+
+ // List the files to get the file ID
+ $result = $this->actingAsForApi($user)
+ ->getJson(
+ route('api.models.files.index', ['model_id' => $model[0]["id"]]))
+ ->assertOk();
+
+ // Delete the file
+ $this->actingAsForApi($user)
+ ->delete(
+ route('api.models.files.destroy', [
+ 'model_id' => $model[0]["id"],
+ 'file_id' => $result->decodeResponseJson()->json()["payload"][0]["id"],
+ ]))
+ ->assertOk();
+ }
+}