category_id= $category_id; } // public function model(array $row) // { // return new FractionalRealEstate([ // // // ]); // } // public function rules(): array // { // return [ // // 'name' => 'required|max:35', // // 'email' => 'required|email|unique:teachers,email,NULL,id,deleted_at,NULL', // // 'phone' => 'required|regex:/^([0-9\s\-\+\(\)]*)$/|min:10', // // 'sex' => 'required|max:1', // // 'dob' => 'required', // // 'qualification' => 'required', // // 'address' => 'required|max:80', // // 'city' => 'required|max:15', // // 'country' => 'required|max:10', // '*.property_name' => 'required', // '*.min_investment' => 'required', // '*.return_rate' => 'required', // ]; // } public function customValidationMessages(Collection $rows) { $messages = []; foreach ($rows as $key => $val) { $messages[''.$key.'.property_name_and_location.required'] = 'Property Name and Location should not be empty at row ' . $key+1; // $messages[''.$key.'.property_name_and_location.unique'] = 'Property Name and Location 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 rules(): array { return [ // '*.property_name_and_location' => 'required|unique:fractional_real_estates,property_name_and_location' // '*.property_name' => 'required|unique:fractional_real_estates,property_name' // '*.min_investment' => 'required', // '*.return_rate' => 'required', ]; } public function collection(Collection $rows) { Validator::make($rows->toArray(), $this->rules(), $this->customValidationMessages($rows))->validate(); // dd($rows); foreach ($rows as $row) { // dd($row['property_name_and_location']); if($row['property_name_and_location'] != '') { $product = Product::create([ 'tables_id' => Table::FractionalRealEstateTable, 'categories_id' => $this->category_id, 'total_views' => 0, // 'status' => 1, 'created_by' => auth()->user()->id, 'description'=> $row['description'] ?? null, ]); $count = FractionalRealEstate::where('property_name_and_location',$row['property_name_and_location'])->count(); FractionalRealEstate::create([ 'products_id' => $product->id, // 'companies_id' => $row['companies_id'], 'slug' => Str::slug($row['property_name_and_location']).'-'.$count+1, 'property_name_and_location' => $row['property_name_and_location'], 'property_description' => $row['description'], 'property_grade' => $row['property_grade'], 'asset_type' => $row['asset_type'], 'tenant' => $row['tenant'], 'deal_size_in_crore' => $row['deal_size_in_crore'], 'coupon_rate_on_ccd' => $row['coupon_rate_on_ccd'], 'rental_escalation' => $row['rental_escalation'], 'capital_appreciation' => $row['capital_appreciation'], 'expected_irr' => $row['expected_irr'], 'cagr' => $row['cagr'], 'minimum_investment' => $row['minimum_investment'], 'minimum_investment_lockin' => $row['minimum_investment_lockin'], 'tenant_lease_term' => $row['tenant_lease_term'], 'tenant_lock_in' => $row['tenant_lock_in'], 'tenant_security_deposit' => $row['tenant_security_deposit'], 'annual_management_fee' => $row['annual_management_fee'], 'performance_fees' => $row['performance_fees'], 'hurdle_rate' => $row['hurdle_rate'], 'minimum_investment_in_int' => $row['minimum_investment_in_int'], ]); } } } }