Skip to content

Commit

Permalink
Merge pull request #13853 from snipe/features/link_back_to_asset_on_c…
Browse files Browse the repository at this point in the history
…reate

Link back to asset on create
  • Loading branch information
snipe authored Nov 13, 2023
2 parents 9e1cfac + 9bff2d0 commit 0bae1a1
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 12 deletions.
6 changes: 1 addition & 5 deletions app/Http/Controllers/Assets/AssetsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,8 @@ public function store(ImageUploadRequest $request)
}

if ($success) {
// Redirect to the asset listing page
$minutes = 518400;
// dd( $_POST['options']);
// Cookie::queue(Cookie::make('optional_info', json_decode($_POST['options']), $minutes));
return redirect()->route('hardware.index')
->with('success', trans('admin/hardware/message.create.success'));
->with('success-unescaped', trans('admin/hardware/message.create.success_linked', ['link' => route('hardware.show', $asset->id), 'id', 'tag' => $asset->asset_tag]));


}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ public function store(Request $request, $component_asset_id, $backto = null)
$asset = Asset::find($component_assets->asset_id);

event(new CheckoutableCheckedIn($component, $asset, Auth::user(), $request->input('note'), Carbon::now()));
if($backto == 'asset'){
return redirect()->route('hardware.view', $asset->id)->with('success',
if ($backto == 'asset'){
return redirect()->route('hardware.show', $asset->id)->with('success',
trans('admin/components/message.checkin.success'));
}

Expand Down
1 change: 1 addition & 0 deletions resources/lang/en/admin/hardware/message.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
'create' => [
'error' => 'Asset was not created, please try again. :(',
'success' => 'Asset created successfully. :)',
'success_linked' => 'Asset with tag :tag was created successfully. <strong><a href=":link" style="color: white;">Click here to view</a></strong>.',
],

'update' => [
Expand Down
12 changes: 12 additions & 0 deletions resources/views/notifications.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@
@endif


@if ($message = Session::get('success-unescaped'))
<div class="col-md-12">
<div class="alert alert-success fade in">
<button type="button" class="close" data-dismiss="alert">&times;</button>
<i class="fas fa-check faa-pulse animated"></i>
<strong>{{ trans('general.notification_success') }}: </strong>
{!! $message !!}
</div>
</div>
@endif


@if ($assets = Session::get('assets'))
@foreach ($assets as $asset)
<div class="col-md-12">
Expand Down
12 changes: 7 additions & 5 deletions routes/web/hardware.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,10 @@ function () {
[AssetCheckinController::class, 'store']
)->name('hardware.checkin.store');

Route::get('{assetId}/view',
[AssetsController::class, 'show']
)->name('hardware.view');
// Redirect old legacy /asset_id/view urls to the resource route version
Route::get('{assetId}/view', function ($assetId) {
return redirect()->route('hardware.show', ['hardware' => $assetId]);
});

Route::get('{assetId}/qr_code',
[AssetsController::class, 'getQrCode']
Expand Down Expand Up @@ -178,14 +179,15 @@ function () {
Route::post('bulkcheckout',
[BulkAssetsController::class, 'storeCheckout']
)->name('hardware.bulkcheckout.store');

});

Route::resource('hardware',
AssetsController::class,
[
'middleware' => ['auth'],
'parameters' => ['asset' => 'asset_id'
],
'parameters' => ['asset' => 'asset_id'],
'names' => ['show' => 'view'],
]);

Route::get('ht/{any?}',
Expand Down

0 comments on commit 0bae1a1

Please sign in to comment.