public function betacheck(Request $request)
 {
     $pkgname = $request->input('pkgname', 'www.chasetch.com');
     $version = $request->input('version', 0);
     $filemd5 = $request->input('md5', 0);
     $deviceid = $request->id;
     $apk = TestApk::where('pkgname', $pkgname)->first();
     if (!empty($apk)) {
         if ($apk->version > $version) {
             echo "have update\n";
             echo action('Api\\UpdateapkController@betadownload', array('token' => $apk->token, 'filename' => $apk->filename)) . "\n";
         } else {
             echo "no update available\n";
         }
     } else {
         echo "apk not found\n";
     }
 }
 public function betadownload(Request $request, $token, $filename)
 {
     $apk = TestApk::where('token', $token)->where('filename', $filename)->first();
     if (!empty($apk)) {
         $pathToFile = storage_path() . "/beta_apk/" . $apk->pkgname . "/" . $apk->filename;
         $apk->downloads = $apk->downloads + 1;
         $apk->update();
         $file = $pathToFile;
         //not public folder
         if (file_exists($file)) {
             header('Content-Description: File Transfer');
             header('Content-Type: application/vnd.android.package-archive');
             header('Content-Disposition: attachment; filename=' . basename($file));
             header('Content-Transfer-Encoding: binary');
             header('Expires: 0');
             header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
             header('Pragma: public');
             header('Content-Length: ' . filesize($file));
             readfile($file);
             exit;
         }
     }
 }