private function matchTwitchStreamsToModpacks()
 {
     $modpacks_array = [];
     $streams_array = [];
     $modpacks = Modpack::all();
     $modpack_aliases = ModpackAlias::all();
     $streams = TwitchStream::where('online', 1)->get();
     foreach ($modpacks as $modpack) {
         $modpacks_array[] = ['id' => $modpack->id, 'name' => $modpack->name];
     }
     foreach ($modpack_aliases as $alias) {
         $modpacks_array[] = ['id' => $alias->modpack_id, 'name' => $alias->alias];
     }
     foreach ($streams as $stream) {
         $id = $stream->channel_id;
         $streams_array[$id] = $stream->status;
     }
     foreach ($streams_array as $s_id => $stream) {
         $stream_database = TwitchStream::find($s_id);
         foreach ($modpacks_array as $mod) {
             preg_match('/' . $mod['name'] . '/i', $stream, $match);
             if ($match) {
                 $stream_database->modpack_id = $mod['id'];
                 $stream_database->save();
                 $this->info('Matched \'' . $stream . '\' to ' . $mod['name']);
                 break;
             } else {
                 $stream_database->delete();
             }
         }
     }
 }
 public function postAdd()
 {
     if (!$this->checkRoute()) {
         return Redirect::route('index');
     }
     $title = 'Add A Modpack Alias - ' . $this->site_name;
     $input = Input::only('alias', 'modpack');
     $messages = ['unique' => 'A code for this launcher/modpack combination already exists in the database!'];
     $validator = Validator::make($input, ['alias' => 'required|unique:modpack_aliases,alias', 'modpack' => 'required'], $messages);
     if ($validator->fails()) {
         return Redirect::action('ModpackAliasController@getAdd')->withErrors($validator)->withInput();
     }
     $modpackalias = new ModpackAlias();
     $modpackalias->alias = $input['alias'];
     $modpackalias->modpack_id = $input['modpack'];
     $success = $modpackalias->save();
     if ($success) {
         return View::make('modpackaliases.add', ['title' => $title, 'success' => true]);
     }
     return Redirect::action('ModpackAliasController@getAdd')->withErrors(['message' => 'Unable to add modpack code.'])->withInput();
 }