diff --git a/routes/web.php b/routes/web.php index 7456d73..ec0ec0d 100644 --- a/routes/web.php +++ b/routes/web.php @@ -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');