/** * Run the database seeds. * * @return void */ public function run() { DB::table('csi_chapters'); $data = [['csi_state_code' => 'DL', 'name' => 'Delhi Chapter'], ['csi_state_code' => 'HR', 'name' => 'Gurgaon Chapter'], ['csi_state_code' => 'UP', 'name' => 'Allahabad Chapter'], ['csi_state_code' => 'UP', 'name' => 'Ghaziabad Chapter'], ['csi_state_code' => 'UP', 'name' => 'Haridwar Chapter'], ['csi_state_code' => 'UP', 'name' => 'Jhansi Chapter'], ['csi_state_code' => 'UP', 'name' => 'Kanpur Chapter'], ['csi_state_code' => 'UP', 'name' => 'Lucknow Chapter'], ['csi_state_code' => 'UP', 'name' => 'Manakpur Chapter'], ['csi_state_code' => 'UP', 'name' => 'Mathura Chapter'], ['csi_state_code' => 'UP', 'name' => 'Noida Chapter'], ['csi_state_code' => 'UP', 'name' => 'Varanasi Chapter'], ['csi_state_code' => 'UT', 'name' => 'Dehradun Chapter'], ['csi_state_code' => 'UT', 'name' => 'Haridwar Chapter'], ['csi_state_code' => 'AS', 'name' => 'Guwahati'], ['csi_state_code' => 'BR', 'name' => 'Patna'], ['csi_state_code' => 'WB', 'name' => 'Durgapur'], ['csi_state_code' => 'WB', 'name' => 'Kolkata'], ['csi_state_code' => 'WB', 'name' => 'Siliguri'], ['csi_state_code' => 'GJ', 'name' => 'Ahmedabad'], ['csi_state_code' => 'GJ', 'name' => 'Rajkot'], ['csi_state_code' => 'GJ', 'name' => 'Surat'], ['csi_state_code' => 'GJ', 'name' => 'V V Nagar'], ['csi_state_code' => 'GJ', 'name' => 'Vadodara'], ['csi_state_code' => 'MP', 'name' => 'Bhopal'], ['csi_state_code' => 'MP', 'name' => 'Gwalior'], ['csi_state_code' => 'MP', 'name' => 'Indore'], ['csi_state_code' => 'MP', 'name' => 'Jabalpur'], ['csi_state_code' => 'MP', 'name' => 'Mhow'], ['csi_state_code' => 'MP', 'name' => 'Ujjain'], ['csi_state_code' => 'RJ', 'name' => 'Chittorgarh'], ['csi_state_code' => 'RJ', 'name' => 'Jaipur'], ['csi_state_code' => 'RJ', 'name' => 'Udaipur'], ['csi_state_code' => 'CT', 'name' => 'Bhilai'], ['csi_state_code' => 'CT', 'name' => 'Raipur'], ['csi_state_code' => 'JH', 'name' => 'Bokaro'], ['csi_state_code' => 'JH', 'name' => 'Dhanbad'], ['csi_state_code' => 'JH', 'name' => 'Jamshedpur'], ['csi_state_code' => 'JH', 'name' => 'Ranchi'], ['csi_state_code' => 'OR', 'name' => 'Balasore'], ['csi_state_code' => 'OR', 'name' => 'Bhubaneswar'], ['csi_state_code' => 'OR', 'name' => 'Cuttack'], ['csi_state_code' => 'OR', 'name' => 'Rourkela'], ['csi_state_code' => 'AP', 'name' => 'Hyderabad'], ['csi_state_code' => 'AP', 'name' => 'K L C E Koneru'], ['csi_state_code' => 'AP', 'name' => 'New Guntur'], ['csi_state_code' => 'AP', 'name' => 'Ongole'], ['csi_state_code' => 'AP', 'name' => 'Vijayawada'], ['csi_state_code' => 'AP', 'name' => 'Visakhapatnam'], ['csi_state_code' => 'KA', 'name' => 'Bangalore'], ['csi_state_code' => 'KA', 'name' => 'Mysore'], ['csi_state_code' => 'GA', 'name' => 'Goa'], ['csi_state_code' => 'MH', 'name' => 'Aurangabad'], ['csi_state_code' => 'MH', 'name' => 'Mumbai'], ['csi_state_code' => 'MH', 'name' => 'Nagpur'], ['csi_state_code' => 'MH', 'name' => 'Nashik'], ['csi_state_code' => 'MH', 'name' => 'Pune'], ['csi_state_code' => 'MH', 'name' => 'Solapur'], ['csi_state_code' => 'KL', 'name' => 'Kozhikode'], ['csi_state_code' => 'KL', 'name' => 'Kochi'], ['csi_state_code' => 'KL', 'name' => 'Trivandrum'], ['csi_state_code' => 'PY', 'name' => 'Puducherry'], ['csi_state_code' => 'TN', 'name' => 'A U Annamalainagar'], ['csi_state_code' => 'TN', 'name' => 'Chennai'], ['csi_state_code' => 'TN', 'name' => 'Coimbatore'], ['csi_state_code' => 'TN', 'name' => 'Hosur'], ['csi_state_code' => 'TN', 'name' => 'Kanyakumari'], ['csi_state_code' => 'TN', 'name' => 'Karaikudi'], ['csi_state_code' => 'TN', 'name' => 'Salem'], ['csi_state_code' => 'TN', 'name' => 'Thanjavur'], ['csi_state_code' => 'TN', 'name' => 'Sivakasi'], ['csi_state_code' => 'TN', 'name' => 'Tiruchirapalli'], ['csi_state_code' => 'TN', 'name' => 'Vellore']]; foreach ($data as $value) { CsiChapter::create($value); } }
public function getResource($resource) { if (is_string($resource)) { if ('amount' == $resource) { $country_code = Input::get('country_code'); $mem_period = Input::get('mem_period'); // hard coding the currency ID to query payment-heads if ('IND' == $country_code) { $currency_id = 1; } else { $currency_id = 2; } Log::info('In getResource: ' . $country_code . $mem_period); $head = PaymentHead::getHead($mem_period, $currency_id)->first(); $data = ['amount' => $head->amount, 'service_tax' => ServiceTaxClass::find($head->service_tax_class_id)->tax_rate]; } else { if ('states' == $resource) { $country_code = Input::get('code'); Log::info('In getResource for states: ' . $country_code); // querying with states of india and not regions > states; $states = State::where('country_code', 'like', $country_code)->orderBy('name', 'asc')->get(['state_code', 'name'])->toarray(); Log::info('In getResource for states: typeof ' . gettype($states)); $data = $states; } else { if ('branches' == $resource) { $state_code = Input::get('code'); Log::info('In getResource for branches: ' . $state_code); $chapters = CsiChapter::where('csi_state_code', $state_code)->get(); $collection = new \Illuminate\Database\Eloquent\Collection(); $result = new \Illuminate\Database\Eloquent\Collection(); foreach ($chapters as $chapter) { $members = Member::where('csi_chapter_id', $chapter->id)->get(); if (!$members->isEmpty()) { $collection = $members->filter(function ($item) { $curr = $item->subType; if ($curr->membership_type_id == 1) { if ($curr->subType->is_student_branch) { return $item; } } }); } } foreach ($collection as $member) { $arr = []; $arr['member_id'] = $member->subType->id; $arr['name'] = $member->subType->name; $result->add($arr); } $data = $result->sortBy('name')->toarray(); } else { if ('chapters' == $resource) { $state_code = Input::get('code'); Log::info('In getResource for chapters: ' . $state_code); $chapters = CsiChapter::where('csi_state_code', $state_code)->orderBy('name', 'asc')->get(['id', 'name'])->toarray(); Log::info('In getResource for chapters: typeof ' . gettype($chapters)); $data = $chapters; } else { if ('institutions' == $resource) { } } } } } $response = Response::json($data, 200); } else { $response = Response::json(array('errors' => $e->getMessage()), 500); } return $response; }
/** * Run the database seeds. * * @return void */ public function run() { $faker = Faker\Factory::create(); /** * academic institution */ factory(Member::class, 'institution', 5)->create()->each(function ($member) use($faker) { Address::create(['type_id' => 1, 'member_id' => $member->id, 'country_code' => 'IND', 'state_code' => CsiChapter::find($member->csi_chapter_id)->state->state_code, 'address_line_1' => $faker->streetAddress, 'city' => State::filterByStateCode(CsiChapter::find($member->csi_chapter_id)->state->state_code)->first()->name, 'pincode' => 110052]); $this->command->info('address done!'); Phone::create(['member_id' => $member->id, 'std_code' => 011, 'landline' => 47028209, 'country_code' => 91, 'mobile' => 1234567890]); $this->command->info('phone done!'); $institution = Institution::create(['member_id' => $member->id, 'membership_type_id' => 1, 'salutation_id' => 1, 'name' => $faker->company, 'head_name' => $faker->name, 'head_designation' => $faker->word, 'email' => $faker->email, 'mobile' => 1234567890]); $this->command->info('institution done!'); AcademicMember::create(['id' => $institution->id, 'institution_type_id' => 2]); $this->command->info('academic done!'); $head = PaymentHead::getHead(1, 1)->first(); $payment = Payment::create(['paid_for' => $member->id, 'payment_head_id' => $head->id, 'service_id' => 1]); $this->command->info('payment done!' . $member->id); $narration = Narration::create(['payer_id' => $member->id, 'mode' => 1, 'transaction_number' => str_random(12), 'bank' => 'sbi', 'branch' => 'kamla nagar', 'date_of_payment' => $faker->date('d/m/Y'), 'drafted_amount' => $head->amount, 'proof' => '6.jpg']); $this->command->info('narration done!'); Journal::create(['payment_id' => $payment->id, 'narration_id' => $narration->id, 'paid_amount' => $head->amount]); $this->command->info('Journal done!'); RequestService::create(['service_id' => Service::getServiceIDByType('membership'), 'payment_id' => $payment->id, 'member_id' => $member->id]); $this->command->info('request done!'); }); /** * non academic institution */ factory(Member::class, 'institution', 5)->create()->each(function ($member) use($faker) { Address::create(['type_id' => 1, 'member_id' => $member->id, 'country_code' => 'IND', 'state_code' => CsiChapter::find($member->csi_chapter_id)->state->state_code, 'address_line_1' => $faker->streetAddress, 'city' => State::filterByStateCode(CsiChapter::find($member->csi_chapter_id)->state->state_code)->first()->name, 'pincode' => 110052]); $this->command->info('address done!'); Phone::create(['member_id' => $member->id, 'std_code' => 011, 'landline' => 47028209, 'country_code' => 91, 'mobile' => 1234567890]); $this->command->info('phone done!'); $institution = Institution::create(['member_id' => $member->id, 'membership_type_id' => 2, 'salutation_id' => 1, 'name' => $faker->company, 'head_name' => $faker->name, 'head_designation' => $faker->word, 'email' => $faker->email, 'mobile' => 1234567890]); $this->command->info('institution done!'); $head = PaymentHead::getHead(9, 1)->first(); $payment = Payment::create(['paid_for' => $member->id, 'payment_head_id' => $head->id, 'service_id' => 1]); $this->command->info('payment done!' . $member->id); $narration = Narration::create(['payer_id' => $member->id, 'mode' => 1, 'transaction_number' => str_random(12), 'bank' => 'sbi', 'branch' => 'kamla nagar', 'date_of_payment' => $faker->date('d/m/Y'), 'drafted_amount' => $head->amount, 'proof' => '6.jpg']); $this->command->info('narration done!'); Journal::create(['payment_id' => $payment->id, 'narration_id' => $narration->id, 'paid_amount' => $head->amount]); $this->command->info('Journal done!'); RequestService::create(['service_id' => Service::getServiceIDByType('membership'), 'payment_id' => $payment->id, 'member_id' => $member->id]); $this->command->info('request done!'); }); /** * professional individual */ factory(Member::class, 'individual', 5)->create()->each(function ($member) use($faker) { Address::create(['type_id' => 1, 'member_id' => $member->id, 'country_code' => 'IND', 'state_code' => CsiChapter::find($member->csi_chapter_id)->state->state_code, 'address_line_1' => $faker->streetAddress, 'city' => State::filterByStateCode(CsiChapter::find($member->csi_chapter_id)->state->state_code)->first()->name, 'pincode' => 110052]); $this->command->info('address done!'); Phone::create(['member_id' => $member->id, 'std_code' => 011, 'landline' => 47028209, 'country_code' => 91, 'mobile' => 1234567890]); $this->command->info('phone done!'); $individual = Individual::create(['member_id' => $member->id, 'membership_type_id' => 4, 'salutation_id' => $faker->randomElement(range(1, 5)), 'first_name' => $faker->firstName, 'middle_name' => $faker->word, 'last_name' => $faker->lastname, 'card_name' => $faker->name, 'gender' => $faker->randomElement(['m', 'f']), 'dob' => $faker->date('d/m/Y')]); $this->command->info('individual done!'); $professional = ProfessionalMember::create(['id' => $individual->id, 'organisation' => $faker->company, 'designation' => $faker->word]); $this->command->info('professional done!'); $head = PaymentHead::getHead(17, 1)->first(); $payment = Payment::create(['paid_for' => $member->id, 'payment_head_id' => $head->id, 'service_id' => 1]); $this->command->info('payment done!' . $member->id); $narration = Narration::create(['payer_id' => $member->id, 'mode' => 1, 'transaction_number' => str_random(12), 'bank' => 'sbi', 'branch' => 'kamla nagar', 'date_of_payment' => $faker->date('d/m/Y'), 'drafted_amount' => $head->amount, 'proof' => '6.jpg']); $this->command->info('narration done!'); Journal::create(['payment_id' => $payment->id, 'narration_id' => $narration->id, 'paid_amount' => $head->amount]); $this->command->info('Journal done!'); RequestService::create(['service_id' => Service::getServiceIDByType('membership'), 'payment_id' => $payment->id, 'member_id' => $member->id]); $this->command->info('request done!'); }); /** * academic individual */ factory(Member::class, 'individual', 5)->create()->each(function ($member) use($faker) { Address::create(['type_id' => 1, 'member_id' => $member->id, 'country_code' => 'IND', 'state_code' => CsiChapter::find($member->csi_chapter_id)->state->state_code, 'address_line_1' => $faker->streetAddress, 'city' => State::filterByStateCode(CsiChapter::find($member->csi_chapter_id)->state->state_code)->first()->name, 'pincode' => 110052]); $this->command->info('address done!'); Phone::create(['member_id' => $member->id, 'std_code' => 011, 'landline' => 47028209, 'country_code' => 91, 'mobile' => 1234567890]); $this->command->info('phone done!'); $individual = Individual::create(['member_id' => $member->id, 'membership_type_id' => 3, 'salutation_id' => $faker->randomElement(range(1, 5)), 'first_name' => $faker->firstName, 'middle_name' => $faker->word, 'last_name' => $faker->lastname, 'card_name' => $faker->name, 'gender' => $faker->randomElement(['m', 'f']), 'dob' => $faker->date('d/m/Y')]); $this->command->info('individual done!'); $student_details = StudentMember::create(['id' => $individual->id, 'student_branch_id' => 1, 'college_name' => $faker->company, 'course_name' => $faker->word, 'course_branch' => $faker->word, 'course_duration' => 3]); $this->command->info('student done!'); $head = PaymentHead::getHead(21, 1)->first(); $payment = Payment::create(['paid_for' => $member->id, 'payment_head_id' => $head->id, 'service_id' => 1]); $this->command->info('payment done!' . $member->id); $narration = Narration::create(['payer_id' => $member->id, 'mode' => 1, 'transaction_number' => str_random(12), 'bank' => 'sbi', 'branch' => 'kamla nagar', 'date_of_payment' => $faker->date('d/m/Y'), 'drafted_amount' => $head->amount, 'proof' => '6.jpg']); $this->command->info('narration done!'); Journal::create(['payment_id' => $payment->id, 'narration_id' => $narration->id, 'paid_amount' => $head->amount]); $this->command->info('Journal done!'); RequestService::create(['service_id' => Service::getServiceIDByType('membership'), 'payment_id' => $payment->id, 'member_id' => $member->id]); $this->command->info('request done!'); }); }