Skip to content

Commit 7f305e3

Browse files
committed
fixed QR code link to find user team by default
1 parent 5b78894 commit 7f305e3

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

routes/web.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,25 @@
1212
config('jetstream.auth_session'),
1313
'verified',
1414
])->group(function () {
15-
/*Route::get('/dashboard', function () {
16-
return view('dashboard');
17-
})->name('dashboard');*/
1815
Route::redirect('/dashboard', '/app')->name('dashboard');
1916
});
20-
//asset_id
17+
2118
Route::get('/a/{asset_id}', function (string $asset_id) {
22-
$asset = \App\Models\Item::where('asset_id', $asset_id)->first();
19+
$team_id = auth()?->user()?->currentTeam()?->getChild()?->id;
20+
// todo: put this logic in one place
21+
$asset_id = ltrim($asset_id, '0');
22+
$asset_id = ltrim($asset_id, '-');
23+
24+
$asset = \App\Models\Item::where('asset_id', $asset_id)
25+
->where('team_id', $team_id)
26+
->first();
2327
if (! $asset) {
2428
// create new empty one with this asset id
2529
$asset = new \App\Models\Item();
2630
$asset->asset_id = $asset_id;
27-
$asset->team_id = auth()?->user()?->currentTeam()?->getChild()?->id;
31+
$asset->team_id = $team_id;
2832
$asset->save();
2933
}
3034

31-
return redirect()->to(ItemResource::getUrl('edit', ['record' => $asset]));
35+
return redirect()->to(ItemResource::getUrl('edit', ['record' => $asset, 'tenant' => $team_id]));
3236
})->name('asset');

0 commit comments

Comments
 (0)