fix:improve access controls and language

also adds improved dialogs / modals
This commit is contained in:
hackerESQ
2024-10-22 16:48:53 -05:00
parent c1a4a44024
commit d1dbf3af62
18 changed files with 154 additions and 59 deletions
+6 -2
View File
@@ -4,7 +4,7 @@ namespace App\Http\Controllers;
use App\Models\Holding;
use App\Models\Portfolio;
use App\Models\DailyChange;
use Illuminate\Http\Request;
class PortfolioController extends Controller
{
@@ -20,8 +20,12 @@ class PortfolioController extends Controller
/**
* Display the specified resource.
*/
public function show(Portfolio $portfolio)
public function show(Request $request, Portfolio $portfolio)
{
if ($request->user()->cannot('readOnly', $portfolio)) {
abort(403);
}
$portfolio->load(['transactions', 'holdings']);
// get portfolio metrics
+11
View File
@@ -69,6 +69,17 @@ class Portfolio extends Model
});
}
public function scopeFullAccess()
{
return $this->whereHas('users', function ($query) {
$query->where('user_id', auth()->user()->id)
->where(function ($query) {
$query->where('full_access', true)
->orWhere('owner', true);
});
});
}
public function scopeWithoutWishlists()
{
return $this->where(['wishlist' => false]);