'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) { MonthlyUpdatePeerToPeerLending::create([ 'custom_id' => $row['custom_id'], 'total_value' => $row['total_value'], 'investment_amount' => $row['investment_amount'], 'all_time_amount_invested' => $row['all_time_amount_invested'], 'interest_accrued' => $row['interest_accrued'], 'principal_redemption' => $row['principal_redemption'], 'net_interest_redemption' => $row['net_interest_redemption'], 'escrow_balance' => $row['escrow_balance'], 'average_roi' => $row['average_roi'], ]); } } }