public function getData()
 {
     $models = new \Illuminate\Support\Collection();
     for ($x = 0; $x < 5; $x++) {
         $models->push($this->generateSet());
     }
     return $models;
 }
 /**
  * Prepare calculation to help with sorting tour
  * @param  [type] $model [description]
  * @return [type]        [description]
  */
 function calculate_min_max_price($model)
 {
     //////////////////////////////////////////////////////////
     // Loop thru each schedules and set the min & max price //
     //////////////////////////////////////////////////////////
     $prices = new \Illuminate\Support\Collection();
     foreach ($model->cheapest_upcoming_schedules as $k => $v) {
         $prices->push($v['price']);
     }
     $calculation = $model->calculation;
     $calculation['price']['upcoming_min'] = $prices->min();
     $calculation['price']['upcoming_max'] = $prices->max();
     $model->calculation = $calculation;
 }
Esempio n. 3
0
 /**
  * Returns a Collection for all weapons..
  *
  * @return \Illuminate\Support\Collection
  */
 public function AllWeapons()
 {
     $weapons_data = $this->alias->weapons->sortBy('name')->groupBy('name');
     $weaponTotal = new \Illuminate\Support\Collection();
     $weaponTotal->primary = new \Illuminate\Support\Collection();
     $weaponTotal->secondary = new \Illuminate\Support\Collection();
     $weaponTotal->tactical = new \Illuminate\Support\Collection();
     $weaponTotal->others = new \Illuminate\Support\Collection();
     foreach ($weapons_data as $key => $weapons) {
         if (in_array($key, [1, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12])) {
             $weaponTotal->primary->{$key} = new \Illuminate\Support\Arr();
             $weaponTotal->primary->push($weaponTotal->primary->{$key});
             $weaponTotal->primary->{$key}->family = "Primary";
             $weaponTotal->primary->{$key}->name = Server\Utils::getEquipmentTitleById($key);
             $weaponTotal->primary->{$key}->id = $key;
             $weaponTotal->primary->{$key}->shots_fired = $weapons->sum('shots_fired');
             $weaponTotal->primary->{$key}->shots_hit = $weapons->sum('shots_hit');
             $weaponTotal->primary->{$key}->kills = $weapons->sum('kills');
             $weaponTotal->primary->{$key}->accuracy = $weaponTotal->primary->{$key}->shots_fired == 0 ? 0 : round($weaponTotal->primary->{$key}->shots_hit / $weaponTotal->primary->{$key}->shots_fired * 100, 2);
             $weaponTotal->primary->{$key}->kills_per_min = $weapons->sum('seconds_used') == 0 ? 0 : round($weaponTotal->primary->{$key}->kills / $weapons->sum('seconds_used') * 60, 2);
             $weaponTotal->primary->{$key}->distance = $weapons->max('distance');
             $weaponTotal->primary->{$key}->time_used = Server\Utils::getHMbyS($weapons->sum('seconds_used'), "%dh %dm");
         } elseif (in_array($key, [13, 14, 15, 16, 17])) {
             $weaponTotal->secondary->{$key} = new \Illuminate\Support\Arr();
             $weaponTotal->secondary->push($weaponTotal->secondary->{$key});
             $weaponTotal->secondary->{$key}->family = "Secondary";
             $weaponTotal->secondary->{$key}->name = Server\Utils::getEquipmentTitleById($key);
             $weaponTotal->secondary->{$key}->id = $key;
             $weaponTotal->secondary->{$key}->shots_fired = $weapons->sum('shots_fired');
             $weaponTotal->secondary->{$key}->shots_hit = $weapons->sum('shots_hit');
             $weaponTotal->secondary->{$key}->kills = $weapons->sum('kills');
             $weaponTotal->secondary->{$key}->accuracy = $weaponTotal->secondary->{$key}->shots_fired == 0 ? 0 : round($weaponTotal->secondary->{$key}->shots_hit / $weaponTotal->secondary->{$key}->shots_fired * 100, 2);
             $weaponTotal->secondary->{$key}->kills_per_min = $weapons->sum('seconds_used') == 0 ? 0 : round($weaponTotal->secondary->{$key}->kills / $weapons->sum('seconds_used') * 60, 2);
             $weaponTotal->secondary->{$key}->distance = $weapons->max('distance');
             $weaponTotal->secondary->{$key}->time_used = Server\Utils::getHMbyS($weapons->sum('seconds_used'), "%dh %dm");
         } elseif (in_array($key, [18, 23, 24, 45, 25, 26])) {
             $weaponTotal->tactical->{$key} = new \Illuminate\Support\Arr();
             $weaponTotal->tactical->push($weaponTotal->tactical->{$key});
             $weaponTotal->tactical->{$key}->family = "Tactical";
             $weaponTotal->tactical->{$key}->name = Server\Utils::getEquipmentTitleById($key);
             $weaponTotal->tactical->{$key}->id = $key;
             $weaponTotal->tactical->{$key}->shots_fired = $weapons->sum('shots_fired');
             $weaponTotal->tactical->{$key}->shots_hit = $weapons->sum('shots_hit');
             $weaponTotal->tactical->{$key}->kills = $weapons->sum('kills');
             $weaponTotal->tactical->{$key}->accuracy = $weaponTotal->tactical->{$key}->shots_fired == 0 ? 0 : round($weaponTotal->tactical->{$key}->shots_hit / $weaponTotal->tactical->{$key}->shots_fired * 100, 2);
             $weaponTotal->tactical->{$key}->stuns_per_min = $weapons->sum('seconds_used') == 0 ? 0 : round($weaponTotal->tactical->{$key}->shots_fired / $weapons->sum('seconds_used') * 60, 2);
             $weaponTotal->tactical->{$key}->distance = $weapons->max('distance');
             $weaponTotal->tactical->{$key}->time_used = Server\Utils::getHMbyS($weapons->sum('seconds_used'), "%dh %dm");
         } else {
             $weaponTotal->others->{$key} = new \Illuminate\Support\Arr();
             $weaponTotal->others->push($weaponTotal->others->{$key});
             $weaponTotal->others->{$key}->family = "Others";
             $weaponTotal->others->{$key}->name = Server\Utils::getEquipmentTitleById($key);
             $weaponTotal->others->{$key}->id = $key;
             $weaponTotal->others->{$key}->shots_fired = $weapons->sum('shots_fired');
             $weaponTotal->others->{$key}->shots_hit = $weapons->sum('shots_hit');
             $weaponTotal->others->{$key}->kills = $weapons->sum('kills');
             $weaponTotal->others->{$key}->accuracy = $weaponTotal->others->{$key}->shots_fired == 0 ? 0 : round($weaponTotal->others->{$key}->shots_hit / $weaponTotal->others->{$key}->shots_fired * 100, 2);
             $weaponTotal->others->{$key}->kills_per_min = $weapons->sum('seconds_used') == 0 ? 0 : round($weaponTotal->others->{$key}->kills / $weapons->sum('seconds_used') * 60, 2);
             $weaponTotal->others->{$key}->distance = $weapons->max('distance');
             $weaponTotal->others->{$key}->time_used = Server\Utils::getHMbyS($weapons->sum('seconds_used'), "%dh %dm");
         }
     }
     $weaponTotal->push($weaponTotal->primary->sortByDesc('kills'))->push($weaponTotal->secondary->sortByDesc('kills'))->push($weaponTotal->tactical->sortByDesc('shots_fired'))->push($weaponTotal->others->sortByDesc('kills'));
     return $weaponTotal;
 }
Esempio n. 4
0
    return redirect('https://www.youtube.com/watch?v=gS65yoNcq88', 307);
});
/*
 * Newsletter routes
 *
 * Muig9%41
 */
Route::group(['middleware' => 'auth', 'prefix' => 'dashboard', 'namespace' => 'Dashboard'], function () {
    Route::get('/', function () {
        return redirect()->route('dashboard.newsletter.index');
    });
    Route::get('/export', function () {
        $newsletters = \App\Newsletter::get();
        $subscriber = new \Illuminate\Support\Collection();
        foreach ($newsletters as $newsletter) {
            $subscriber->push(['id' => $newsletter->id, 'email' => $newsletter->email]);
        }
        Excel::create('Newsletter_Subscriber', function ($excel) use($subscriber) {
            $excel->sheet('Subscriber', function ($sheet) use($subscriber) {
                $sheet->fromArray($subscriber, null, 'A1', false);
            });
        })->download('csv');
    });
    Route::get('/newsletter', ['as' => 'dashboard.newsletter.index', 'uses' => 'NewsletterController@index']);
});
/*
 * Authentication routes
 */
Route::get('auth/login', 'Auth\\AuthController@getLogin');
Route::post('auth/login', ['uses' => 'Auth\\AuthController@postLogin']);
Route::get('auth/logout', 'Auth\\AuthController@getLogout');
Esempio n. 5
0
 public function testCachedFeatureFirst()
 {
     $this->createContent(10);
     $this->createContentLang(10);
     $this->assertCount(10, Content::all());
     $this->assertCount(100, Model\ContentLang::all());
     $collection = new \Illuminate\Support\Collection();
     \DB::flushQueryLog();
     Content::all()->each(function ($item) use($collection) {
         $wrapper = $this->wrapper->createNew($item, 1);
         $collection->push($wrapper);
     });
     Content::all()->each(function ($item) use($collection) {
         $wrapper = $this->wrapper->createNew($item, 2);
         $collection->push($wrapper);
     });
     $this->assertCount(20, $collection);
     for ($i = 0; $i < 10; $i++) {
         foreach ($collection as $one) {
             $one->title;
             $one->content;
             $one->enable;
             $one->visible;
         }
     }
     $this->assertCount(5, \DB::getQueryLog());
 }