Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/Http/Controllers/Api/MaintenancesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ public function index(Request $request) : JsonResponse | array
$maintenances->where('maintenances.created_by', '=', $request->input('created_by'));
}

if ($request->filled('url')) {
$maintenances->where('maintenances.url', '=', $request->input('url'));
}

if ($request->filled('asset_maintenance_type')) {
$maintenances->where('asset_maintenance_type', '=', $request->input('asset_maintenance_type'));
}
Expand Down
2 changes: 2 additions & 0 deletions app/Http/Controllers/MaintenancesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public function store(ImageUploadRequest $request) : RedirectResponse
$maintenance->is_warranty = $request->input('is_warranty');
$maintenance->cost = $request->input('cost');
$maintenance->notes = $request->input('notes');
$maintenance->url = $request->input('url');

// Save the asset maintenance data
$maintenance->asset_id = $asset->id;
Expand Down Expand Up @@ -152,6 +153,7 @@ public function update(ImageUploadRequest $request, Maintenance $maintenance) :
$maintenance->name = $request->input('name');
$maintenance->start_date = $request->input('start_date');
$maintenance->completion_date = $request->input('completion_date');
$maintenance->url = $request->input('url');


// Todo - put this in a getter/setter?
Expand Down
1 change: 1 addition & 0 deletions app/Http/Transformers/MaintenancesTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public function transformMaintenance(Maintenance $assetmaintenance)
'id' => $assetmaintenance->supplier->id,
'name'=> e($assetmaintenance->supplier->name)
] : null,
'url' => ($assetmaintenance->url) ? e($assetmaintenance->url) : null,
'cost' => Helper::formatCurrencyOutput($assetmaintenance->cost),
'asset_maintenance_type' => e($assetmaintenance->asset_maintenance_type),
'start_date' => Helper::getFormattedDateObject($assetmaintenance->start_date, 'date'),
Expand Down
2 changes: 2 additions & 0 deletions app/Models/Maintenance.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class Maintenance extends SnipeModel implements ICompanyableChild
'completion_date' => 'date_format:Y-m-d|nullable|after_or_equal:start_date',
'notes' => 'string|nullable',
'cost' => 'numeric|nullable|gte:0|max:99999999999999999.99',
'url' => 'nullable|url|max:255',
];


Expand All @@ -57,6 +58,7 @@ class Maintenance extends SnipeModel implements ICompanyableChild
'asset_maintenance_time',
'notes',
'cost',
'url',
];

use Searchable;
Expand Down
6 changes: 6 additions & 0 deletions app/Presenters/MaintenancesPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ public static function dataTableLayout()
'sortable' => true,
'title' => trans('admin/maintenances/form.completion_date'),
'formatter' => 'dateDisplayFormatter',
], [
'field' => 'url',
'searchable' => true,
'sortable' => true,
'title' => trans('general.url'),
'formatter' => 'externalLinkFormatter',
], [
'field' => 'notes',
'searchable' => true,
Expand Down
1 change: 1 addition & 0 deletions database/factories/MaintenanceFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public function definition()
'start_date' => $this->faker->date(),
'is_warranty' => $this->faker->boolean(),
'notes' => $this->faker->paragraph(),
'url' => $this->faker->url(),
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('maintenances', function (Blueprint $table) {
if (!Schema::hasColumn('maintenances', 'url')) {
$table->text('url')->after('name')->nullable()->default(null);
}
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('maintenances', function (Blueprint $table) {
if (Schema::hasColumn('maintenances', 'url')) {
$table->dropColumn('url');
}
});
}
};
10 changes: 10 additions & 0 deletions resources/views/maintenances/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
</div>
</div>


<!-- Asset Maintenance Cost -->
<div class="form-group {{ $errors->has('cost') ? ' has-error' : '' }}">
<label for="cost" class="col-md-3 control-label">{{ trans('admin/maintenances/form.cost') }}</label>
Expand All @@ -171,6 +172,15 @@
</div>
</div>

<div class="form-group {{ $errors->has('url') ? ' has-error' : '' }}">
<label for="url" class="col-md-3 control-label">{{ trans('general.url') }}</label>
<div class="col-md-7">
<input class="form-control" name="url" type="url" id="url" value="{{ old('url', $item->url) }}" placeholder="https://example.com">
{!! $errors->first('url', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
</div>
</div>


@include ('partials.forms.edit.image-upload', ['image_path' => app('maintenances_path')])


Expand Down
14 changes: 14 additions & 0 deletions resources/views/maintenances/view.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,20 @@
</div>
</div> <!-- /row -->

@if ($maintenance->url)
<div class="row">
<div class="col-md-3">
{{ trans('general.url') }}
</div>
<div class="col-md-9">
<a href="{{ $maintenance->url }}">
{{ $maintenance->url }}
<x-icon type="external-link" />
</a>
</div>
</div> <!-- /row -->
@endif

<div class="row">
<div class="col-md-3">
{{ trans('admin/maintenances/form.asset_maintenance_time') }}
Expand Down
2 changes: 2 additions & 0 deletions tests/Feature/Maintenances/Api/CreateMaintenanceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public function testCanCreateMaintenance()
'completion_date' => '2021-01-10',
'is_warranty' => '1',
'cost' => '100.00',
'url' => 'https://snipeitapp.com',
'image' => UploadedFile::fake()->image('test_image.png'),
'notes' => 'A note',
])
Expand All @@ -62,6 +63,7 @@ public function testCanCreateMaintenance()
'start_date' => '2021-01-01',
'completion_date' => '2021-01-10',
'notes' => 'A note',
'url' => 'https://snipeitapp.com',
'image' => $maintenance->image,
'created_by' => $actor->id,
]);
Expand Down
2 changes: 2 additions & 0 deletions tests/Feature/Maintenances/Api/EditMaintenanceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public function testCanEditMaintenance()
'is_warranty' => '1',
'image' => UploadedFile::fake()->image('test_image.png'),
'notes' => 'A note',
'url' => 'https://snipeitapp.com',
])
->assertOk();

Expand All @@ -57,6 +58,7 @@ public function testCanEditMaintenance()
'completion_date' => '2021-01-10',
'asset_maintenance_time' => '9',
'notes' => 'A note',
'url' => 'https://snipeitapp.com',
'image' => $maintenance->image,
]);

Expand Down
2 changes: 2 additions & 0 deletions tests/Feature/Maintenances/Ui/CreateMaintenanceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public function testCanCreateMaintenance()
'cost' => '100.00',
'image' => UploadedFile::fake()->image('test_image.png'),
'notes' => 'A note',
'url' => 'https://snipeitapp.com',
])
->assertSessionHasNoErrors()
->assertRedirect(route('maintenances.index'));
Expand All @@ -67,6 +68,7 @@ public function testCanCreateMaintenance()
'completion_date' => '2021-01-10',
'asset_maintenance_time' => '9',
'notes' => 'A note',
'url' => 'https://snipeitapp.com',
'cost' => '100.00',
'image' => $maintenance->image,
'created_by' => $actor->id,
Expand Down
2 changes: 2 additions & 0 deletions tests/Feature/Maintenances/Ui/EditMaintenanceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public function testCanUpdateMaintenance()
'image' => UploadedFile::fake()->image('test_image.png'),
'cost' => '100.99',
'notes' => 'A note',
'url' => 'https://snipeitapp.com',
])
->assertSessionHasNoErrors()
->assertRedirect(route('maintenances.index'));
Expand All @@ -58,6 +59,7 @@ public function testCanUpdateMaintenance()
'completion_date' => '2021-01-10',
'asset_maintenance_time' => '9',
'notes' => 'A note',
'url' => 'https://snipeitapp.com',
'cost' => '100.99',
]);

Expand Down
Loading