Ejemplo n.º 1
0
 function addDetails($request, $key)
 {
     $address = Addresses::create(['line1' => $request['line1'][$key], 'line2' => $request['line2'][$key], 'suburb' => $request['suburb'][$key], 'state' => $request['state'][$key], 'postcode' => $request['postcode'][$key], 'country' => $request['country'][$key]]);
     $employment = EmploymentDetails::create(['employment_type' => $request['employment_type'][$key], 'job_title' => $request['job_title'][$key], 'starting_date' => $request['starting_date'][$key], 'business_name' => $request['business_name'][$key], 'abn' => $request['abn'][$key], 'contact_person' => $request['contact_person'][$key], 'contact_person_job_title' => $request['contact_person_job_title'][$key], 'contact_number' => $request['contact_number'][$key], 'address_id' => $address->id, 'is_current' => 1, 'applicant_id' => $request['applicant_id'][$key]]);
     if ($request['employment_type'][$key] == "Self Employed") {
         $accountant = new AccountantDetails();
         $accountant->add($employment->id, $request, $key);
     }
     EmploymentIncome::create(['annual_gross_income' => $request['annual_gross_income'][$key], 'pay_frequency' => $request['pay_frequency'][$key], 'salary_crediting' => $request['salary_crediting'][$key], 'credit_to_where' => $request['credit_to_where'][$key], 'latest_pay_date' => $request['latest_pay_date'][$key], 'latest_payslip_period_from' => $request['latest_payslip_period_from'][$key], 'latest_payslip_period_to' => $request['latest_payslip_period_to'][$key], 'employment_detail_id' => $employment->id, 'applicant_id' => $request['applicant_id'][$key]]);
 }
Ejemplo n.º 2
0
 function addProperty($request, $key)
 {
     $address = Addresses::create(['line1' => $request['line1'][$key], 'line2' => $request['line2'][$key], 'suburb' => $request['suburb'][$key], 'state' => $request['state'][$key], 'postcode' => $request['postcode'][$key], 'country' => $request['country'][$key]]);
     $property = Property::create(['taken_as_security' => $request['taken_as_security'][$key], 'market_value' => $request['market_value'][$key], 'property_usage' => $request['property_usage'][$key], 'applicant_id' => $request['applicant_id'][$key], 'property_type' => $request['property_type'][$key], 'number_of_bedrooms' => $request['number_of_bedrooms'][$key], 'number_of_bathrooms' => $request['number_of_bathrooms'][$key], 'number_of_car_spaces' => $request['number_of_car_spaces'][$key], 'size' => $request['size'][$key], 'title_particulars' => $request['title_particulars'][$key], 'title_type' => $request['title_type'][$key], 'address_id' => $address->id]);
     ValuationAccess::create(['access_party' => $request['access_party'][$key], 'contact_person' => $request['contact_person'][$key], 'phone_number' => $request['phone_number'][$key], 'property_id' => $property->id]);
     if ($request['rental_income'][$key] == 1) {
         Income::create(['property_id' => $property->id, 'type' => 'property', 'weekly_rental' => $request['weekly_rental'][$key], 'credit_to' => $request['credit_to'][$key]]);
     }
     if ($request['existing_loans'][$key] == 1) {
         ExistingLoan::create(['ownership' => $request['ownership'][$key], 'to_be_cleared' => $request['to_be_cleared'][$key], 'lender' => $request['lender'][$key], 'loan_type' => $request['loan_type'][$key], 'fixed_rate_term' => $request['fixed_rate_term'][$key], 'fixed_rate_expiry_date' => $request['fixed_rate_expiry_date'][$key], 'limit' => $request['limit'][$key], 'balance' => $request['balance'][$key], 'property_id' => $property->id]);
     }
     $property->save();
     return $property->id;
 }
Ejemplo n.º 3
0
 public function add($employment_id, $request, $key)
 {
     $business_address = Addresses::create(['line1' => $request['accountant_line1'][$key], 'line2' => $request['accountant_line2'][$key], 'suburb' => $request['accountant_suburb'][$key], 'state' => $request['accountant_state'][$key], 'postcode' => $request['accountant_postcode'][$key], 'country' => $request['accountant_country'][$key]]);
     AccountantDetails::create(['accountant_business_name' => $request['accountant_business_name'][$key], 'contact_person' => $request['accountant_contact_person'][$key], 'phone_number' => $request['accountant_phone_number'][$key], 'business_address_id' => $business_address->id, 'employment_details_id' => $employment_id]);
 }
Ejemplo n.º 4
0
 function addAddressDetails($request, $key, $applicant_id)
 {
     $home_address = Addresses::create(['line1' => $request['home_line1'][$key], 'line2' => $request['home_line2'][$key], 'suburb' => $request['home_suburb'][$key], 'state' => $request['home_state'][$key], 'postcode' => $request['home_postcode'][$key], 'country' => $request['home_country'][$key]]);
     ApplicantAddress::create(['address_id' => $home_address->id, 'applicant_id' => $applicant_id, 'iscurrent' => 1, 'address_type_id' => 1, 'live_there_since' => $request['live_there_since'][$key]]);
     /*RentExpense::create([
           'weekly_rent_expense' => $request['weekly_rent_expense'][$key],
           'applicant_id' => $applicant_id,
           'debit_from' => $request['debit_from'][$key]
       ]);*/
     $postal_address = Addresses::create(['line1' => $request['postal_line1'][$key], 'line2' => $request['postal_line2'][$key], 'suburb' => $request['postal_suburb'][$key], 'state' => $request['postal_state'][$key], 'postcode' => $request['postal_postcode'][$key], 'country' => $request['postal_country'][$key]]);
     ApplicantAddress::create(['address_id' => $postal_address->id, 'applicant_id' => $applicant_id, 'iscurrent' => 0, 'address_type_id' => 3]);
     $previous_address = Addresses::create(['line1' => $request['previous_line1'][$key], 'line2' => $request['previous_line2'][$key], 'suburb' => $request['previous_suburb'][$key], 'state' => $request['previous_state'][$key], 'postcode' => $request['previous_postcode'][$key], 'country' => $request['previous_country'][$key]]);
     ApplicantAddress::create(['address_id' => $previous_address->id, 'applicant_id' => $applicant_id, 'iscurrent' => 0, 'address_type_id' => 4]);
 }
Ejemplo n.º 5
0
 function edit(array $request, $client_id)
 {
     DB::beginTransaction();
     try {
         $client = Client::find($client_id);
         $client->preferred_name = $request['preferred_name'];
         $client->given_name = $request['given_name'];
         $client->surname = $request['surname'];
         $client->email = $request['email'];
         $client->salary = $request['salary'];
         $client->occupation = $request['occupation'];
         $client->salary_type = $request['salary_type'];
         $client->introducer = $request['introducer'];
         $client->title = $request['title'];
         $client->save();
         /* Delete associated addresses and phone numbers... change this later for code optimization */
         Client::find($client_id)->client_addresses()->with('address')->delete();
         Client::find($client_id)->client_phones()->with('phone')->delete();
         //change this later for multiple addresses
         $address = Addresses::create(['line1' => $request['line1'], 'line2' => $request['line2'], 'suburb' => $request['suburb'], 'state' => $request['state'], 'postcode' => $request['postcode'], 'country' => $request['country']]);
         ClientAddress::create(['ex_clients_id' => $client->id, 'address_type_id' => 1, 'is_current' => 1, 'address_id' => $address->id]);
         /* Add Phone numbers*/
         $phone_numbers = $request['phone'];
         foreach ($phone_numbers as $key => $phone_num) {
             if ($phone_num != '') {
                 $phone = Phone::create(['number' => $phone_num, 'type' => $request['phonetype'][$key]]);
                 ClientPhone::create(['phones_id' => $phone->id, 'ex_clients_id' => $client->id]);
             }
         }
         DB::commit();
         return $client->id;
         // all good
     } catch (\Exception $e) {
         DB::rollback();
         dd($e);
         // something went wrong
     }
     if ($client) {
         return true;
     } else {
         return false;
     }
 }