Exemplo n.º 1
0
 private function storeStudentIndividual()
 {
     $var = DB::transaction(function ($connection) {
         $membership_period = Input::get('membership-period');
         $salutation = Input::get('salutation');
         $fname = Input::get('fname');
         $mname = Input::get('mname');
         $lname = Input::get('lname');
         $card_name = Input::get('card_name');
         $dob = Input::get('dob');
         $gender = Input::get('gender');
         $country = Input::get('country');
         $state = Input::get('state');
         $stud_branch = Input::get('stud_branch');
         $address = Input::get('address');
         $city = Input::get('city');
         $pincode = Input::get('pincode');
         $college = Input::get('college');
         $course = Input::get('course');
         $cbranch = Input::get('cbranch');
         $cduration = Input::get('cduration');
         $email1 = Input::get('email1');
         $email2 = Input::get('email2');
         $std = Input::get('std');
         $phone = Input::get('phone');
         $country_code = Input::get('country-code');
         $mobile = Input::get('mobile');
         $paymentMode = Input::get('paymentMode');
         $tno = Input::get('tno');
         $drawn = Input::get('drawn');
         $bank = Input::get('bank');
         $branch = Input::get('branch');
         $paymentReciept = Input::file('paymentReciept');
         $amountPaid = Input::get('amountPaid');
         $student_branch = AcademicMember::find($stud_branch);
         $chapter = $student_branch->institution->member->csi_chapter_id;
         $member = new Member();
         $member->membership_id = 2;
         // individual member
         $membership_type = 3;
         // student member
         $member->csi_chapter_id = $chapter;
         $member->email = $email1;
         $member->email_extra = $email2;
         $member->password = bcrypt('1234');
         $member->save();
         $member->id;
         $filename = $member->id . '.';
         $filename .= $paymentReciept->getClientOriginalExtension();
         Address::create(['type_id' => 1, 'member_id' => $member->id, 'country_code' => $country, 'state_code' => $state, 'address_line_1' => $address, 'city' => $city, 'pincode' => $pincode]);
         Phone::create(['member_id' => $member->id, 'std_code' => $std, 'landline' => $phone, 'country_code' => $country_code, 'mobile' => $mobile]);
         $paymentReciept->move(storage_path('uploads/payment_proofs'), $filename);
         $individual = Individual::create(['member_id' => $member->id, 'membership_type_id' => $membership_type, 'salutation_id' => $salutation, 'first_name' => $fname, 'middle_name' => $mname, 'last_name' => $lname, 'card_name' => $card_name, 'gender' => $gender, 'dob' => $dob]);
         $student_details = StudentMember::create(['id' => $individual->id, 'student_branch_id' => $student_branch->id, 'college_name' => $college, 'course_name' => $course, 'course_branch' => $cbranch, 'course_duration' => $cduration]);
         // 2nd arg is currency.. needs to be queried to put here
         $head = PaymentHead::getHead($membership_period, 1)->first();
         $payment = Payment::create(['paid_for' => $member->id, 'payment_head_id' => $head->id, 'service_id' => 1]);
         $narration = Narration::create(['payer_id' => $member->id, 'mode' => $paymentMode, 'transaction_number' => $tno, 'bank' => $bank, 'branch' => $branch, 'date_of_payment' => $drawn, 'drafted_amount' => $head->amount, 'proof' => $filename]);
         $journal = Journal::create(['payment_id' => $payment->id, 'narration_id' => $narration->id, 'paid_amount' => $amountPaid]);
         $request = RequestService::create(['service_id' => Service::getServiceIDByType('membership'), 'payment_id' => $payment->id, 'member_id' => $member->id]);
         return $member;
     });
     return $var;
 }