This commit is contained in:
hackerESQ
2024-08-29 23:36:44 -05:00
parent 2febed20ae
commit df1071d628
13 changed files with 204 additions and 64 deletions
+16 -15
View File
@@ -12,25 +12,26 @@ use Maatwebsite\Excel\Concerns\WithValidation;
class PortfoliosSheet implements ToCollection, WithValidation, WithHeadingRow, SkipsEmptyRows
{
// use Importable;
public function collection(Collection $portfolios)
{
foreach ($portfolios as $portfolio) {
Portfolio::withoutEvents(function () use ($portfolios) {
foreach ($portfolios as $portfolio) {
auth()->user()->portfolios()
->where(['id' => $portfolio['portfolio_id']])
->orWhere(['title' => $portfolio['title']])
->firstOr(function () use ($portfolio) {
auth()->user()->portfolios()
->where(['id' => $portfolio['portfolio_id']])
->orWhere(['title' => $portfolio['title']])
->firstOr(function () use ($portfolio) {
return Portfolio::make()->forceFill([
'id' => $portfolio['portfolio_id'] ?? null,
'title' => $portfolio['title'],
'wishlist' => $portfolio['wishlist'] ?? false,
'notes' => $portfolio['notes'],
])->save();
});
}
return Portfolio::make()->forceFill([
'id' => $portfolio['portfolio_id'] ?? null,
'title' => $portfolio['title'],
'wishlist' => $portfolio['wishlist'] ?? false,
'notes' => $portfolio['notes'],
])->save();
});
}
});
}
public function rules(): array