public function getSearch()
 {
     if (!Input::has('username')) {
         return Redirect::to(route('admin.account.index'));
     }
     $username = Input::get('username');
     $accounts = Account::with(['user', 'game'])->withTrashed()->where('username', 'like', "%{$username}%")->paginate(20);
     $pageTitle = 'Search for : ' . $username;
     return view('admin.account.index', ['accounts' => $accounts, 'page_title' => $pageTitle]);
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $validator = Validator::make($request->all(), ['nama_akun' => 'required'], ['nama_akun.required' => 'Nama akun tidak boleh kosong.']);
     if ($validator->fails()) {
         return redirect()->back()->withErrors($validator)->withInput();
     }
     $account = Account::with('reports')->find($id);
     $inReports = $request->get('reports') != "" ? $request->get('reports') : [];
     $accountReports = array_column($account->reports->toArray(), 'id');
     if ($account->update($request->all())) {
         // for new reports
         $newReports = array_diff($inReports, $accountReports);
         if (count($newReports)) {
             $account->assignReport($newReports);
         }
         // for delete reports
         $deleteReports = array_diff($accountReports, $inReports);
         if (count($deleteReports)) {
             $account->revokeReport($deleteReports);
         }
         return redirect('/account')->with('succcess', 'Sukses ubah data akun.');
     }
     return redirect()->back()->withErrors(['failed' => 'Gagal ubah data akun.']);
 }