'required|unique:bonds,issuer' // '*.property_name' => 'required|unique:fractional_real_estates,property_name' // '*.min_investment' => 'required', // '*.return_rate' => 'required', ]; } public function customValidationMessages(Collection $rows) { $messages = []; foreach ($rows as $key => $val) { $messages['' . $key . '.issuer.required'] = 'Issuer should not be empty at row ' . $key + 1; $messages['' . $key . '.issuer.unique'] = 'Issuer is not unique at row ' . $key + 1; } return $messages; // return [ // '*.property_name.required' => 'Property name must not be empty!' // // '*.min_investment.required' => 'Minimun Investment must not be empty!', // // '*.return_rate.required' => 'Return Rate must not be empty!' // ]; } public function collection(Collection $rows) { Validator::make($rows->toArray(), $this->rules(), $this->customValidationMessages($rows))->validate(); foreach ($rows as $row) { MonthlyUpdateIndianFinancialAssets::create([ 'custom_id' => $row['custom_id'] ?? null, 'investment_date' => $row['investment_date'] ?? null, 'amount_invested' => $row['amount_invested'] ?? null, 'total_gross_repaid_amount' => $row['total_gross_repaid_amount'] ?? null, 'tenure_in_days' => $row['tenure_days'] ?? null, 'principal_payment_frequency' => $row['principal_payment_frequency'] ?? null, 'interest_payment_frequency' => $row['interest_payment_frequency'] ?? null, 'next_repayment_due_date' => $row['next_repayment_due_date'] ?? null, 'maturity_date' => $row['maturity_date'] ?? null, 'next_repayment_amount' => $row['next_repayment_amount'] ?? null, 'expected_irr' => $row['expected_irr'] ?? null, ]); } } }