Exemplo n.º 1
0
 function editAddress($request, $id, $key)
 {
     $address = Addresses::find($id);
     $address->line1 = $request['line1'][$key];
     $address->line2 = $request['line2'][$key];
     $address->suburb = $request['suburb'][$key];
     $address->state = $request['state'][$key];
     $address->postcode = $request['postcode'][$key];
     $address->country = $request['country'][$key];
     $address->save();
 }
Exemplo n.º 2
0
 function editAccountantAddress($address_id, $request, $key)
 {
     $business_address = Addresses::find($address_id);
     $business_address->line1 = $request['accountant_line1'][$key];
     $business_address->line2 = $request['accountant_line2'][$key];
     $business_address->suburb = $request['accountant_suburb'][$key];
     $business_address->state = $request['accountant_state'][$key];
     $business_address->postcode = $request['accountant_postcode'][$key];
     $business_address->country = $request['accountant_country'][$key];
     $business_address->save();
 }
Exemplo n.º 3
0
 function remove($client_id)
 {
     DB::beginTransaction();
     try {
         //get details
         $client = Client::find($client_id);
         //change this later for multiple addresses
         $client_address = ClientAddress::where('ex_clients_id', $client->id)->first();
         $address = Addresses::find($client_address->address_id);
         //phone numbers
         $all_client_phones = ClientPhone::where('ex_clients_id', $client->id);
         $client_phones = $all_client_phones->get();
         $all_client_phones->delete();
         /* delete data */
         //delete phone numbers
         if (!empty($client_phones)) {
             foreach ($client_phones as $client_phone) {
                 $phones = Phone::find($client_phone->phones_id)->delete();
             }
         }
         //delete address
         $client_address->delete();
         $address->delete();
         //delete client
         $client->delete();
         DB::commit();
         // all good
     } catch (\Exception $e) {
         DB::rollback();
         dd($e);
         // something went wrong
     }
 }