Esempio n. 1
0
    } else {
        return View::make('page.torrent.rate');
    }
});
Route::get('earn/cashout', function () {
    if (Auth::guest()) {
        return Redirect::guest('signin');
    } else {
        return View::make('page.torrent.cashout');
    }
});
Route::post('earn/cashout', function () {
    if (Auth::guest()) {
        return Redirect::guest('signin');
    } else {
        $pr = PayRequest::where('user_id', '=', Auth::user()->id)->where('done', '=', 0)->first();
        if (isset($pr->id)) {
            return Redirect::to('earn/cashout')->with(array('errors' => 'You\'ve already requested for a cash out!'));
        } else {
            if (Input::has('email')) {
                if (filter_var(Input::get('email'), FILTER_VALIDATE_EMAIL)) {
                } else {
                    return Redirect::to('earn/cashout')->with(array('errors' => 'Invalid email address!'));
                }
                $country_data = DB::table('share_usage')->where('perc', '>', 50)->where('user_id', '=', Auth::user()->id)->select('country', DB::raw('count(*) as total'))->groupBy('country')->get();
                $total_user_earnings = 0;
                foreach ($country_data as $cd) {
                    $rate = DB::table('pay_rate')->where('name', 'LIKE', '%' . $cd->country . '%')->first();
                    if ($cd->total != 0) {
                        $rate_thousand = $cd->total / 1000;
                        if (isset($rate->id)) {