Skip to content

Commit

Permalink
Merge pull request #942 from ladybirdweb/development
Browse files Browse the repository at this point in the history
Laravel Version update
  • Loading branch information
Ashutosh pathak authored Feb 2, 2020
2 parents a29d133 + 39f664f commit f5b389c
Show file tree
Hide file tree
Showing 5,797 changed files with 99,885 additions and 321,535 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
12 changes: 6 additions & 6 deletions app/Http/Controllers/Auth/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,13 @@ public function requestOtp(Request $request)
'mobile' => 'required|numeric',
]);

$number = $request->oldnumber;
$newNumber = $request->newnumber;
$number = ltrim($request->oldnumber, '0');
$newNumber = ltrim($request->newnumber, '0');
User::where('mobile', $number)->update(['mobile'=>$newNumber]);

try {
$code = $request->input('code');
$mobile = $request->input('mobile');
$mobile = ltrim($request->input('mobile'), '0');
$number = '(+'.$code.') '.$mobile;
$result = $this->sendOtp($mobile, $code);
$response = ['type' => 'success', 'message' => 'OTP has been sent to '.$number.'.Please Verify to Login'];
Expand All @@ -191,7 +191,7 @@ public function retryOTP(Request $request)

try {
$code = $request->input('code');
$mobile = $request->input('mobile');
$mobile = ltrim($request->input('mobile'), '0');
$otp = $request->input('otp');
$number = '(+'.$code.') '.$mobile;
$result = $this->sendForReOtp($mobile, $code, $request->input('type'));
Expand Down Expand Up @@ -231,7 +231,7 @@ public function verifyOtp($mobile, $code, $otp)
$client = new \GuzzleHttp\Client();
$key = ApiKey::where('id', 1)->value('msg91_auth_key');
$number = $code.$mobile;
$response = $client->request('GET', 'https://control.msg91.com/api/verifyRequestOTP.php', [
$response = $client->request('GET', 'https://api.msg91.com/api/v5/otp/verify', [
'query' => ['authkey' => $key, 'mobile' => $number, 'otp' => $otp],
]);

Expand All @@ -246,7 +246,7 @@ public function postOtp(Request $request)

try {
$code = $request->input('code');
$mobile = $request->input('mobile');
$mobile = ltrim($request->input('mobile'), '0');
$otp = $request->input('otp');
$userid = $request->input('id');
$verify = $this->verifyOtp($mobile, $code, $otp);
Expand Down
12 changes: 7 additions & 5 deletions app/Http/Controllers/Auth/BaseAuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ public static function sendOtp($mobile, $code)
$client = new \GuzzleHttp\Client();
$number = $code.$mobile;
$key = ApiKey::where('id', 1)->select('msg91_auth_key', 'msg91_sender')->first();
$response = $client->request('GET', 'https://control.msg91.com/api/sendotp.php', [

$response = $client->request('GET', 'https://api.msg91.com/api/v5/otp', [
'query' => ['authkey' => $key->msg91_auth_key, 'mobile' => $number, 'sender'=>$key->msg91_sender],
]);
$send = $response->getBody()->getContents();
Expand All @@ -73,7 +74,8 @@ public function sendForReOtp($mobile, $code, $type)
$client = new \GuzzleHttp\Client();
$number = $code.$mobile;
$key = ApiKey::where('id', 1)->value('msg91_auth_key');
$response = $client->request('GET', 'https://control.msg91.com/api/retryotp.php', [

$response = $client->request('GET', 'https://api.msg91.com/api/v5/otp/retry', [
'query' => ['authkey' => $key, 'mobile' => $number, 'retrytype'=>$type],
]);
$send = $response->getBody()->getContents();
Expand All @@ -97,13 +99,13 @@ public function requestOtpFromAjax(Request $request)
]);
$email = $request->oldemail;
$newEmail = $request->newemail;
$number = $request->oldnumber;
$newNumber = $request->newnumber;
$number = ltrim($request->oldnumber, '0');
$newNumber = ltrim($request->newnumber, '0');
User::where('email', $email)->update(['email'=>$newEmail, 'mobile'=>$newNumber]);

try {
$code = $request->input('code');
$mobile = $request->input('mobile');
$mobile = ltrim($request->input('mobile'), '0');
$userid = $request->input('id');
$email = $request->input('email');
$pass = $request->input('password');
Expand Down
33 changes: 24 additions & 9 deletions app/Http/Controllers/BaseHomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,6 @@ public function verifyOrder($order_number, $serial_key)
}
}

public function hook(Request $request)
{
try {
\Log::info('requests', $request->all());
} catch (\Exception $ex) {
dd($ex);
}
}

public function index()
{
$totalSales = $this->getTotalSales();
Expand Down Expand Up @@ -171,4 +162,28 @@ public function checkUpdatesExpiry(Request $request)
return $result;
}
}

public function updateLatestVersion(Request $request)
{
try {
$orderId = null;
$licenseCode = $request->input('licenseCode');
$orderForLicense = Order::all()->filter(function ($order) use ($licenseCode) {
if ($order->serial_key == $licenseCode) {
return $order;
}
});
if (count($orderForLicense) > 0) {
$latestVerison = Subscription::where('order_id', $orderForLicense->first()->id)->update(['version'=>$request->input('version')]);

return ['status' => 'success', 'message' => 'version-updated-successfully'];
}

return ['status' => 'fails', 'message' => 'version-not updated'];
} catch (\Exception $e) {
$result = ['status'=>'fails', 'error' => $e->getMessage()];

return $result;
}
}
}
4 changes: 3 additions & 1 deletion app/Http/Controllers/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,9 @@ public function expiringSubscription()
$dayUtc = new Carbon('+30 days');
$today = Carbon::now()->toDateTimeString();
$plus30Day = $dayUtc->toDateTimeString();
$subsEnds = Subscription::where('update_ends_at', '>', $today)->where('update_ends_at', '<=', $plus30Day)
$subsEnds = Subscription::where('update_ends_at', '>', $today)->where('update_ends_at', '<=', $plus30Day)->whereHas('order', function($query) {
$query->where('price_override', '>', 0);
})
->orderBy('update_ends_at', 'ASC')->get();

return $subsEnds;
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/Front/BaseClientController.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class='btn btn-sm btn-primary'><i class='fa fa-download'>
/**
* Update Profile.
*/
public function postProfile(ProfileRequest $request)
public function postProfile(ProfileRequest $request)
{
try {
$user = \Auth::user();
Expand Down
14 changes: 8 additions & 6 deletions app/Http/Controllers/Front/CheckoutController.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,13 @@ public function postCheckout(Request $request)
$paynow = $this->checkregularPaymentOrRenewal($request->input('invoice_id'));
$cost = $request->input('cost');
$state = $this->getState();
if (Cart::getSubTotal() != 0 || $cost > 0) {
$this->validate($request, [
'payment_gateway'=> 'required',
], [
'payment_gateway.required'=> 'Please Select a Payment Gateway',
]);
}

try {
if ($paynow === false) {
Expand Down Expand Up @@ -233,11 +240,6 @@ public function postCheckout(Request $request)
$attributes = $this->getAttributes($content);
}
if (Cart::getSubTotal() != 0 || $cost > 0) {
$this->validate($request, [
'payment_gateway'=> 'required',
], [
'payment_gateway.required'=> 'Please Select a Payment Gateway',
]);
if ($payment_method == 'razorpay') {
$rzp_key = ApiKey::where('id', 1)->value('rzp_key');
$rzp_secret = ApiKey::where('id', 1)->value('rzp_secret');
Expand All @@ -262,7 +264,7 @@ public function postCheckout(Request $request)
)
);
} else {
\Event::fire(new \App\Events\PaymentGateway(['request' => $request, 'cart' => Cart::getContent(), 'order' => $invoice]));
\Event::dispatch(new \App\Events\PaymentGateway(['request' => $request, 'cart' => Cart::getContent(), 'order' => $invoice]));
}
} else {
if ($paynow == false) {//Regular Payment for free Product
Expand Down
5 changes: 3 additions & 2 deletions app/Http/Controllers/Front/ClientController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use DateTimeZone;
use Exception;
use GrahamCampbell\Markdown\Facades\Markdown;
use Illuminate\Http\Request;

class ClientController extends BaseClientController
{
Expand Down Expand Up @@ -405,10 +406,10 @@ public function getPaymentByOrderId($orderid, $userid)

return \DataTables::of($payments->get())
->addColumn('checkbox', function ($model) {
if (\Input::get('client') != 'true') {

return "<input type='checkbox' class='payment_checkbox'
value=".$model->id.' name=select[] id=check>';
}

})
->addColumn('number', function ($model) {
return $model->invoice()->first()->number;
Expand Down
35 changes: 0 additions & 35 deletions app/Http/Controllers/Github/GithubApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,40 +111,5 @@ public function convertHeaderToArray($header_text, $response)
}
}

public function testCurl()
{
$url = 'http://www.faveohelpdesk.com/billing/test-curl-result';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
$content = curl_exec($ch);
curl_close($ch);
echo $content;
}

public function testCurlResult()
{
return 'success';
}

public function getCurl12($url)
{
try {
if (str_contains($url, ' ')) {
$url = str_replace(' ', '', $url);
}
$context = stream_context_create([
'http' => [
'method' => 'GET',
'header' => [
"User-Agent:$this->username",
'Authorization: Basic '.base64_encode("$this->username:$this->password"),
],
],
]);
$data = file_get_contents($url, false, $context);
dd($data);
} catch (\Exception $e) {
dd($e);
}
}
}
92 changes: 90 additions & 2 deletions app/Http/Controllers/Order/ExtendedOrderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use App\Http\Controllers\Controller;
use App\Model\Common\StatusSetting;
use App\Model\Order\Order;
use Carbon\Carbon;
use App\Model\Product\Subscription;
use Bugsnag;
use Illuminate\Http\Request;
Expand Down Expand Up @@ -36,7 +37,10 @@ public function advanceSearch(
$expiryTill = '',
$from = '',
$till = '',
$domain = ''
$domain = '',
$paidUnpaid = '',
$allInstallation = '',
$version = ''
) {
try {
$join = Order::leftJoin('subscriptions', 'orders.id', '=', 'subscriptions.order_id');
Expand All @@ -47,7 +51,9 @@ public function advanceSearch(
$this->orderFrom($till, $from, $join);
$this->orderTill($from, $till, $join);
$this->domain($domain, $join);

$this->paidOrUnpaid($paidUnpaid,$join);
$this->allInstallations($allInstallation,$join);
$this->getSelectedVersionOrders($version,$join);
$join = $join->orderBy('created_at', 'desc')
->select(
'orders.id',
Expand All @@ -66,6 +72,88 @@ public function advanceSearch(
}
}


/**
* Searches for order for selected versions
*
* @author Ashutosh Pathak <[email protected]>
*
*
* @param string $version
* @param App\Model\Order $join The order instance
*
* @return $join
*/
private function getSelectedVersionOrders($version,$join)
{
if($version) {
$currentVer = ($version[0] == 'v') ? $version : 'v'.$version;
$join = $join->whereHas('subscription', function($query) use($currentVer) {
$query->where('version', '=', $currentVer);
});
}
return $join;
}

/**
* Searches for Active/Inactive Installation
*
* @author Ashutosh Pathak <[email protected]>
*
* @date 2020-01-29T17:35:05+0530
*
* @param string $allInstallation
* @param App\Model\Order $join The order instance
*
* @return $join
*/
public function allInstallations($allInstallation,$join)
{
if($allInstallation) {
$dayUtc = new Carbon('-30 days');
$minus30Day = $dayUtc->toDateTimeString();
if($allInstallation == 'paid_ins') {
$join = $join->where('price_override', '>', 0)->whereHas('subscription', function($query) use($minus30Day) {
$query->where('updated_at', '>', $minus30Day);
});
} elseif($allInstallation == 'unpaid_ins') {
$join = $join->where('price_override', '=', 0)->whereHas('subscription', function($query) use($minus30Day) {
$query->where('updated_at', '>', $minus30Day);
});
} elseif ($allInstallation == 'all_ins') {
$join = $join->whereHas('subscription', function($query) use($minus30Day) {
$query->where('updated_at', '>', $minus30Day);
});
}
}
return $join;
}

/**
* Searches for Paid/Unpaid Products
*
* @author Ashutosh Pathak <[email protected]>
*
* @date 2020-01-29T17:35:05+0530
*
* @param string $paidUnpaid
* @param App\Model\Order $join The order instance
*
* @return $join
*/
private function paidOrUnpaid($paidUnpaid,$join)
{
if($paidUnpaid) {
if($paidUnpaid == 'paid') {
$join = $join->where('price_override', '>', 0);
} elseif($paidUnpaid == 'unpaid') {
$join = $join->where('price_override', '=', 0);
}

}
return $join;
}

/**
* Searches for Order No.
*
Expand Down
1 change: 0 additions & 1 deletion app/Http/Controllers/Order/InvoiceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
use App\User;
use Bugsnag;
use Illuminate\Http\Request;
use Input;

class InvoiceController extends TaxRatesAndCodeExpiryController
{
Expand Down
Loading

0 comments on commit f5b389c

Please sign in to comment.