Merge branch 'develop' into fixes/17956-handle-force-deleted-model-in-asset-edit
This commit is contained in:
@@ -163,7 +163,7 @@ class BulkAssetsController extends Controller
|
||||
$modelNames = [];
|
||||
|
||||
foreach($models as $model) {
|
||||
$modelNames[] = $model->model->name;
|
||||
$modelNames[] = $model->model?->name;
|
||||
}
|
||||
|
||||
if ($request->filled('bulk_actions')) {
|
||||
@@ -470,7 +470,7 @@ class BulkAssetsController extends Controller
|
||||
*/
|
||||
|
||||
// Does the model have a fieldset?
|
||||
if ($asset->model->fieldset) {
|
||||
if ($asset->model?->fieldset) {
|
||||
foreach ($asset->model->fieldset->fields as $field) {
|
||||
|
||||
// null custom fields
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
@endphp
|
||||
|
||||
@foreach($models as $model)
|
||||
@if ($model->fieldset ? $model->fieldset->count() > 0 : false)
|
||||
@if (($model) && ($model->fieldset ? $model->fieldset->count() > 0 : false))
|
||||
@php
|
||||
$anyModelHasCustomFields++;
|
||||
@endphp
|
||||
|
||||
@@ -29,6 +29,25 @@ class BulkEditAssetsTest extends TestCase
|
||||
])->assertStatus(200);
|
||||
}
|
||||
|
||||
public function test_handles_model_being_deleted()
|
||||
{
|
||||
$this->withoutExceptionHandling();
|
||||
|
||||
$user = User::factory()->viewAssets()->editAssets()->create();
|
||||
$assets = Asset::factory()->count(2)->create();
|
||||
|
||||
$assets->first()->model->forceDelete();
|
||||
|
||||
$id_array = $assets->pluck('id')->toArray();
|
||||
|
||||
$this->actingAs($user)->post('/hardware/bulkedit', [
|
||||
'ids' => $id_array,
|
||||
'order' => 'asc',
|
||||
'bulk_actions' => 'edit',
|
||||
'sort' => 'id'
|
||||
])->assertStatus(200);
|
||||
}
|
||||
|
||||
public function test_standard_user_cannot_access_page()
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
|
||||
Reference in New Issue
Block a user