hide holding page if qty = 0

This commit is contained in:
hackerESQ
2024-08-30 20:25:45 -05:00
parent 8b86dace13
commit b13bb198d3
+5 -1
View File
@@ -14,7 +14,6 @@ class HoldingController extends Controller
*/
public function show(Request $request, Portfolio $portfolio, String $symbol)
{
$holding = Holding::with([
'market_data',
'transactions' => function ($query) use ($symbol) {
@@ -25,6 +24,11 @@ class HoldingController extends Controller
->portfolio($portfolio->id)
->firstOrFail();
if ($holding->quantity <= 0) {
return redirect(route('portfolio.show', ['portfolio' => $portfolio->id]));
}
return view('holding.show', compact(['portfolio', 'holding']));
}
}