Exemplo n.º 1
0
 public function decline($bannerId)
 {
     $banner = Banner::findOrFail($bannerId);
     if ($banner->twitcher_id != $this->user->id) {
         return redirect('/user/twitcher');
     }
     if ($banner->is_active == 1 || $banner->status != 'waiting') {
         return redirect('/user/twitcher');
     }
     BannerMapper::declineBanner($banner);
     return Redirect::to('/user/twitcher')->with(['success' => 'You declined banner']);
 }
Exemplo n.º 2
0
 public function addBanners($limit = 2000)
 {
     $clients = User::whereType('client')->get();
     $twitchers = User::whereType('twitcher')->get();
     $bannerTypes = $this->data['bannerTypes'];
     $faker = $this->faker;
     $i = 0;
     foreach ($clients as $c) {
         try {
             $bannerCounts = rand(0, 4);
             if ($i > $limit) {
                 //continue;
             }
             for ($i = 0; $i < $bannerCounts; $i++) {
                 $bannerType = $bannerTypes->random();
                 $twitcher = $twitchers->random();
                 if (BannerMapper::twitcherFree($twitcher, $bannerType->id)) {
                     $limit = rand(0, $c->balance);
                     if ($limit > 0) {
                         $requiredSizes = explode('*', $bannerType->title);
                         $w = $requiredSizes[0];
                         $h = $requiredSizes[1];
                         $file = $faker->imageUrl($w, $h);
                         $banner = BannerMapper::addForTwitcher($twitcher, $c, $bannerType, $file, $limit);
                         NotificationMapper::bannerAdd($banner);
                         LogMapper::log('banner_add', $banner->id);
                         $accept = rand(0, 10);
                         $i++;
                         if ($accept != 0) {
                             BannerMapper::acceptBanner($banner);
                         } else {
                             BannerMapper::declineBanner($banner);
                         }
                     }
                 }
             }
         } catch (\Exception $e) {
             dd($e->getTraceAsString());
         }
     }
 }