fix: speeds up imports with batched transactions and daily changes

This commit is contained in:
hackerESQ
2024-10-28 18:35:14 -05:00
parent 41377757ec
commit 82a84cec97
3 changed files with 129 additions and 60 deletions
+24
View File
@@ -0,0 +1,24 @@
<?php
namespace App\Imports;
use App\Models\Portfolio;
trait ValidatesPortfolioAccess
{
public function validatePortfolioAccess($collection)
{
$uniquePortfolios = $collection->unique('portfolio_id')->pluck('portfolio_id');
$countPortfoliosWithAccess = Portfolio::fullAccess($this->backupImport->user_id)
->whereIn('id', $uniquePortfolios)
->count();
if (
$countPortfoliosWithAccess < $uniquePortfolios->count()
) {
throw new \Exception(__("You do not have access to that portfolio."));
}
}
}