/**
  * A function to retrieve all faucets associated with a
  * payment processor.
  *
  * @param $paymentProcessorSlug
  * @return array|null
  */
 public function paymentProcessorFaucets($paymentProcessorSlug)
 {
     try {
         //Obtain payment processor by related slug.
         $paymentProcessor = PaymentProcessor::findBySlug($paymentProcessorSlug);
         // Use model relationship to obtain associated faucets
         $faucets = $paymentProcessor->faucets;
         $activeFaucets = [];
         // Iterate over all related faucets,
         // obtaining only ones that are active.
         foreach ($faucets as $f) {
             if ($f->is_paused == false && $f->has_low_balance == false) {
                 array_push($activeFaucets, $f);
             }
         }
         return $activeFaucets;
     } catch (Exception $e) {
         return null;
     }
 }
 /**
  * Update the specified payment processor in storage.
  *
  * @param $slug
  * @return Response
  */
 public function update($slug)
 {
     // Obtain payment processor tp update
     $paymentProcessor = PaymentProcessor::findBySlug($slug);
     $id = $paymentProcessor->id;
     // Create validator to validate form data used to update payment processor.
     $validator = Validator::make(Input::all(), PaymentProcessorValidator::validationRulesEdit($id));
     // If validation fails, redirect to pre-populated form.
     if ($validator->fails()) {
         return Redirect::to('/admin/payment_processors/' . $slug . '/edit')->withErrors($validator)->withInput(Input::all());
     }
     // If validation passes, store updated details for
     // payment processor into database.
     $paymentProcessor->fill(Input::all());
     $paymentProcessor->save();
     Session::flash('success_message', 'The payment processor has successfully been updated!');
     return Redirect::to('/payment_processors/' . $slug);
 }