fix: speeds up imports with batched transactions and daily changes
This commit is contained in:
@@ -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."));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user