2024-08-26 19:54:45 -05:00
|
|
|
<?php
|
|
|
|
|
|
2025-01-28 17:33:54 -06:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2024-08-26 19:54:45 -05:00
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
2024-08-28 23:32:01 -05:00
|
|
|
use App\Models\Holding;
|
2024-08-26 21:34:13 -05:00
|
|
|
use App\Models\Portfolio;
|
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
|
2024-08-26 19:54:45 -05:00
|
|
|
class HoldingController extends Controller
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Display the specified resource.
|
|
|
|
|
*/
|
2025-01-28 17:14:49 -06:00
|
|
|
public function show(Request $request, Portfolio $portfolio, string $symbol)
|
2024-08-26 19:54:45 -05:00
|
|
|
{
|
2024-08-29 20:55:23 -05:00
|
|
|
$holding = Holding::with([
|
2025-01-28 17:14:49 -06:00
|
|
|
'market_data',
|
|
|
|
|
'transactions' => function ($query) use ($symbol) {
|
|
|
|
|
$query->where('transactions.symbol', $symbol);
|
|
|
|
|
},
|
|
|
|
|
])
|
2025-08-29 02:54:54 +00:00
|
|
|
->symbol($symbol)
|
|
|
|
|
->portfolio($portfolio->id)
|
|
|
|
|
->firstOrFail();
|
2024-08-27 21:17:54 -05:00
|
|
|
|
2024-10-31 17:04:59 -05:00
|
|
|
$formattedTransactions = $holding->getFormattedTransactions();
|
2024-10-31 12:09:06 -05:00
|
|
|
|
|
|
|
|
return view('holding.show', compact(['portfolio', 'holding', 'formattedTransactions']));
|
|
|
|
|
}
|
2024-08-26 19:54:45 -05:00
|
|
|
}
|