Skip to content

Commit

Permalink
fixed QR code link to find user team by default
Browse files Browse the repository at this point in the history
  • Loading branch information
Flatroy committed Jul 9, 2024
1 parent 5b78894 commit 7f305e3
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,25 @@
config('jetstream.auth_session'),
'verified',
])->group(function () {
/*Route::get('/dashboard', function () {
return view('dashboard');
})->name('dashboard');*/
Route::redirect('/dashboard', '/app')->name('dashboard');
});
//asset_id

Route::get('/a/{asset_id}', function (string $asset_id) {
$asset = \App\Models\Item::where('asset_id', $asset_id)->first();
$team_id = auth()?->user()?->currentTeam()?->getChild()?->id;
// todo: put this logic in one place
$asset_id = ltrim($asset_id, '0');
$asset_id = ltrim($asset_id, '-');

$asset = \App\Models\Item::where('asset_id', $asset_id)
->where('team_id', $team_id)
->first();
if (! $asset) {
// create new empty one with this asset id
$asset = new \App\Models\Item();
$asset->asset_id = $asset_id;
$asset->team_id = auth()?->user()?->currentTeam()?->getChild()?->id;
$asset->team_id = $team_id;
$asset->save();
}

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

0 comments on commit 7f305e3

Please sign in to comment.