/**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $data = $this->csv_to_array(base_path() . '/database/seeds/csv_files/faucets.csv');
     foreach ($data as $d) {
         $url = $d['url'];
         try {
             $meta = new WebsiteMeta($url);
             $faucet = new Faucet(['name' => $d['name'], 'url' => $url, 'interval_minutes' => (int) $d['interval_minutes'], 'min_payout' => (int) $d['min_payout'], 'max_payout' => (int) $d['max_payout'], 'has_ref_program' => $d['has_ref_program'], 'ref_payout_percent' => (int) $d['ref_payout_percent'], 'comments' => $d['comments'], 'is_paused' => $d['comments'], 'meta_title' => $meta->title(), 'meta_description' => $meta->description(), 'meta_keywords' => $meta->keywords(), 'has_low_balance' => false]);
             $faucet->save();
         } catch (Exception $e) {
             error_log($e->getMessage() . "<br>" . 'The URL "' . $url . '" does not exist or is experiencing technical issues.');
         }
     }
 }
 public function run()
 {
     DB::statement('SET FOREIGN_KEY_CHECKS = 0');
     DB::table('referral_info')->truncate();
     $user_id = User::where('user_name', env('ADMIN_USERNAME'))->first()->id;
     $faucets = Faucet::all();
     foreach ($faucets as $faucet) {
         DB::table('referral_info')->insert(array(['faucet_id' => $faucet->id, 'user_id' => $user_id]));
     }
     DB::statement('SET FOREIGN_KEY_CHECKS = 1');
 }
 /**
  * Create and download faucets/payment processors linking data as CSV file.
  */
 public function getFaucetsPaymentProcessorsLinkingData()
 {
     $faucets = Faucet::all();
     $csv = Writer::createFromFileObject(new SplTempFileObject());
     $csv->insertOne(Schema::getColumnListing('faucet_payment_processor'));
     foreach ($faucets as $f) {
         $paymentProcessors = $f->paymentProcessors()->get();
         foreach ($paymentProcessors as $p) {
             $data = ['faucet_id' => $f->id, 'payment_processor_id' => $p->id];
             $csv->insertOne($data);
         }
     }
     $csv->output('faucets_payment_processors.csv');
 }
Ejemplo n.º 4
0
 /**
  * A function used to tweet the details of a Random faucet.
  */
 public function sendRandomFaucetTweet()
 {
     $faucetIds = Faucet::where('id', '>', 0)->pluck('id')->toArray();
     shuffle($faucetIds);
     $randomNumber = array_slice($faucetIds, 0, 1);
     //Obtain a faucet using the random integer.
     $faucet = Faucet::find($randomNumber[0]);
     if ($faucet != null) {
         //Construct a message template based on the random faucet's details.
         $message = "Earn between " . $faucet->min_payout . " and " . $faucet->max_payout . " satoshis every " . $faucet->interval_minutes . " minute/s from " . url('/faucets/' . $faucet->slug) . " for free :).";
         // Send the tweet of the random faucet.
         $this->sendTweet($message);
     }
 }
 /**
  * A function used to update the 'low balance' status of a
  * faucet.
  *
  * @param $faucetSlug
  * @return mixed
  */
 public static function lowBalance($faucetSlug)
 {
     try {
         $lowBalanceStatus = Input::get('has_low_balance');
         $faucet = Faucet::findBySlugOrId($faucetSlug);
         $faucet->has_low_balance = $lowBalanceStatus;
         $faucet->save();
         Session::flash('success_message_update_faucet_low_balance_status', 'The faucet has been paused due to low balance (less than 10,000 Satoshis).');
         return Redirect::to('faucets/' . $faucetSlug);
     } catch (ModelNotFoundException $e) {
         abort(404);
     } catch (Exception $e) {
         return Redirect::to('faucets/' . $faucetSlug)->withErrors(['There was a problem changing low balance status, please try again.'])->withInput(Input::get('has_low_balance'));
     }
 }
 /**
  * A function used to tweet the details of a Random faucet.
  */
 public function sendRandomFaucetTweet()
 {
     $faucetCount = count(Faucet::all());
     if ($faucetCount > 0) {
         //Obtain a random integer used to
         //get a random faucet to tweet.
         $numbers = range(0, $faucetCount - 1);
         shuffle($numbers);
         $randomNumber = array_slice($numbers, 0, 1);
         //Obtain a faucet using the random integer.
         $faucet = Faucet::find($randomNumber[0]);
         //Construct a message template based on the random faucet's details.
         $message = "Earn between " . $faucet->min_payout . " and " . $faucet->max_payout . " satoshis every " . $faucet->interval_minutes . " minute/s from " . url('/faucets/' . $faucet->slug) . " for free :).";
         // Send the tweet of the random faucet.
         $this->sendTweet($message);
     }
 }
 /**
  * A function to retrieve all active faucets.
  *
  * @param bool|false $hasLowBalance
  * @return array|null
  */
 public function activeFaucets($hasLowBalance = false)
 {
     try {
         //Get all faucets, regardless of low-balance or active/paused status.
         $faucets = Faucet::all()->sortBy('interval_minutes')->values()->all();
         $activeFaucets = [];
         //Iterate over all faucets, check their low-balance and active/pause status,
         //then put desired faucets in separate faucets array.
         foreach ($faucets as $f) {
             if ($f->is_paused == false && $f->has_low_balance == $hasLowBalance) {
                 array_push($activeFaucets, $f);
             }
         }
         //Return active faucets.
         return $activeFaucets;
     } catch (Exception $e) {
         return null;
     }
 }
 /**
  * Remove the specified faucet from storage.
  *
  * @param $slug
  * @return Response
  * @internal param int $id
  */
 public function destroy($slug)
 {
     try {
         $faucet = Faucet::findBySlugOrId($slug);
         $faucetName = $faucet->name;
         $faucetUrl = $faucet->url;
         $faucet->paymentProcessors()->detach();
         $faucet->users()->detach();
         $faucet->delete();
         Session::flash('success_message_delete', 'The faucet "' . $faucetName . '" with URL "' . $faucetUrl . '" has successfully been deleted!');
         return Redirect::to('faucets');
     } catch (ModelNotFoundException $e) {
         abort(404);
     }
 }
Ejemplo n.º 9
0
 public function postResetAll(ResetAllRequest $request)
 {
     $data = $request->all();
     $result = Faucet::where('until', '>', date('Y-m-d H:i:s'))->update(['until' => date('Y-m-d H:i:s')]);
     return Response::json(['message' => 'All faucets reset to current date!!!', 'id' => $data['id']]);
 }