@@ -65,7 +65,7 @@ |
||
| 65 | 65 | **/ |
| 66 | 66 | public function latest() |
| 67 | 67 | { |
| 68 | - return $this->updates->orderBy('version','DESC')->first(); |
|
| 68 | + return $this->updates->orderBy('version', 'DESC')->first(); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | |
@@ -6,41 +6,41 @@ |
||
| 6 | 6 | class ElimuswiftCoreServiceProvider extends ServiceProvider |
| 7 | 7 | { |
| 8 | 8 | |
| 9 | - /** |
|
| 10 | - * Bootstrap the application services. |
|
| 11 | - * |
|
| 12 | - * @return void |
|
| 13 | - */ |
|
| 14 | - public function boot() |
|
| 15 | - { |
|
| 16 | - $this->loadFiles(); |
|
| 17 | - } |
|
| 18 | - |
|
| 19 | - |
|
| 20 | - /** |
|
| 21 | - * Register the application services. |
|
| 22 | - * |
|
| 23 | - * @return void |
|
| 24 | - */ |
|
| 25 | - public function register() |
|
| 26 | - { |
|
| 27 | - $this->app->singleton('envatoapi', function(){ |
|
| 28 | - return new EnvatoApi(env('ENVATO_SECRET')); |
|
| 29 | - }); |
|
| 30 | - |
|
| 31 | - $this->app->bind('Elimuswift\Core\Repositories\Contracts\RepositoryContract', 'Elimuswift\Core\Repositories\UpdatesRepository'); |
|
| 32 | - } |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * Load and publish app migration files |
|
| 36 | - * |
|
| 37 | - * @return void |
|
| 38 | - * |
|
| 39 | - **/ |
|
| 40 | - protected function loadFiles() |
|
| 41 | - { |
|
| 42 | - $this->loadMigrationsFrom(__DIR__.'/Migrations'); |
|
| 43 | - $this->loadRoutesFrom(__DIR__.'/routes.php'); |
|
| 44 | - } |
|
| 9 | + /** |
|
| 10 | + * Bootstrap the application services. |
|
| 11 | + * |
|
| 12 | + * @return void |
|
| 13 | + */ |
|
| 14 | + public function boot() |
|
| 15 | + { |
|
| 16 | + $this->loadFiles(); |
|
| 17 | + } |
|
| 18 | + |
|
| 19 | + |
|
| 20 | + /** |
|
| 21 | + * Register the application services. |
|
| 22 | + * |
|
| 23 | + * @return void |
|
| 24 | + */ |
|
| 25 | + public function register() |
|
| 26 | + { |
|
| 27 | + $this->app->singleton('envatoapi', function(){ |
|
| 28 | + return new EnvatoApi(env('ENVATO_SECRET')); |
|
| 29 | + }); |
|
| 30 | + |
|
| 31 | + $this->app->bind('Elimuswift\Core\Repositories\Contracts\RepositoryContract', 'Elimuswift\Core\Repositories\UpdatesRepository'); |
|
| 32 | + } |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * Load and publish app migration files |
|
| 36 | + * |
|
| 37 | + * @return void |
|
| 38 | + * |
|
| 39 | + **/ |
|
| 40 | + protected function loadFiles() |
|
| 41 | + { |
|
| 42 | + $this->loadMigrationsFrom(__DIR__.'/Migrations'); |
|
| 43 | + $this->loadRoutesFrom(__DIR__.'/routes.php'); |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | 46 | } |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | */ |
| 25 | 25 | public function register() |
| 26 | 26 | { |
| 27 | - $this->app->singleton('envatoapi', function(){ |
|
| 27 | + $this->app->singleton('envatoapi', function() { |
|
| 28 | 28 | return new EnvatoApi(env('ENVATO_SECRET')); |
| 29 | 29 | }); |
| 30 | 30 | |
@@ -6,30 +6,30 @@ |
||
| 6 | 6 | |
| 7 | 7 | class CreateUpdatesTable extends Migration |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * Run the migrations. |
|
| 11 | - * |
|
| 12 | - * @return void |
|
| 13 | - */ |
|
| 14 | - public function up() |
|
| 15 | - { |
|
| 16 | - Schema::create('updates', function (Blueprint $table) { |
|
| 17 | - $table->increments('id'); |
|
| 18 | - $table->string('version',10); |
|
| 19 | - $table->string('type'); |
|
| 20 | - $table->text('description'); |
|
| 21 | - $table->integer('downloads'); |
|
| 22 | - $table->timestamps(); |
|
| 23 | - }); |
|
| 24 | - } |
|
| 9 | + /** |
|
| 10 | + * Run the migrations. |
|
| 11 | + * |
|
| 12 | + * @return void |
|
| 13 | + */ |
|
| 14 | + public function up() |
|
| 15 | + { |
|
| 16 | + Schema::create('updates', function (Blueprint $table) { |
|
| 17 | + $table->increments('id'); |
|
| 18 | + $table->string('version',10); |
|
| 19 | + $table->string('type'); |
|
| 20 | + $table->text('description'); |
|
| 21 | + $table->integer('downloads'); |
|
| 22 | + $table->timestamps(); |
|
| 23 | + }); |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Reverse the migrations. |
|
| 28 | - * |
|
| 29 | - * @return void |
|
| 30 | - */ |
|
| 31 | - public function down() |
|
| 32 | - { |
|
| 33 | - Schema::dropIfExists('updates'); |
|
| 34 | - } |
|
| 26 | + /** |
|
| 27 | + * Reverse the migrations. |
|
| 28 | + * |
|
| 29 | + * @return void |
|
| 30 | + */ |
|
| 31 | + public function down() |
|
| 32 | + { |
|
| 33 | + Schema::dropIfExists('updates'); |
|
| 34 | + } |
|
| 35 | 35 | } |
@@ -13,9 +13,9 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | public function up() |
| 15 | 15 | { |
| 16 | - Schema::create('updates', function (Blueprint $table) { |
|
| 16 | + Schema::create('updates', function(Blueprint $table) { |
|
| 17 | 17 | $table->increments('id'); |
| 18 | - $table->string('version',10); |
|
| 18 | + $table->string('version', 10); |
|
| 19 | 19 | $table->string('type'); |
| 20 | 20 | $table->text('description'); |
| 21 | 21 | $table->integer('downloads'); |
@@ -40,17 +40,17 @@ discard block |
||
| 40 | 40 | * @return string Guzzle\Response::getBody() |
| 41 | 41 | * @param string $code |
| 42 | 42 | **/ |
| 43 | - public function getPurchaseData( $code ) |
|
| 43 | + public function getPurchaseData($code) |
|
| 44 | 44 | { |
| 45 | - $ch_verify = curl_init( $this->url. $code ); |
|
| 46 | - curl_setopt( $ch_verify, CURLOPT_HTTPHEADER, $this->headers ); |
|
| 47 | - curl_setopt( $ch_verify, CURLOPT_SSL_VERIFYPEER, false ); |
|
| 48 | - curl_setopt( $ch_verify, CURLOPT_RETURNTRANSFER, 1 ); |
|
| 49 | - curl_setopt( $ch_verify, CURLOPT_CONNECTTIMEOUT, 5 ); |
|
| 50 | - curl_setopt( $ch_verify, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13'); |
|
| 45 | + $ch_verify = curl_init($this->url.$code); |
|
| 46 | + curl_setopt($ch_verify, CURLOPT_HTTPHEADER, $this->headers); |
|
| 47 | + curl_setopt($ch_verify, CURLOPT_SSL_VERIFYPEER, false); |
|
| 48 | + curl_setopt($ch_verify, CURLOPT_RETURNTRANSFER, 1); |
|
| 49 | + curl_setopt($ch_verify, CURLOPT_CONNECTTIMEOUT, 5); |
|
| 50 | + curl_setopt($ch_verify, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13'); |
|
| 51 | 51 | |
| 52 | - $cinit_verify_data = curl_exec( $ch_verify ); |
|
| 53 | - curl_close( $ch_verify ); |
|
| 52 | + $cinit_verify_data = curl_exec($ch_verify); |
|
| 53 | + curl_close($ch_verify); |
|
| 54 | 54 | |
| 55 | 55 | if ($cinit_verify_data != "") |
| 56 | 56 | return json_decode($cinit_verify_data, true); |
@@ -65,11 +65,11 @@ discard block |
||
| 65 | 65 | * @return mixed Array |
| 66 | 66 | * @param string $code Purchase Code |
| 67 | 67 | **/ |
| 68 | - public function verifyPurchase(string $code ) |
|
| 68 | + public function verifyPurchase(string $code) |
|
| 69 | 69 | { |
| 70 | 70 | $purchase = []; |
| 71 | 71 | $purchase['response'] = (object) $this->getPurchaseData($code); |
| 72 | - if($purchase->error) |
|
| 72 | + if ($purchase->error) |
|
| 73 | 73 | return $purchase['status'] => 'error'; |
| 74 | 74 | else |
| 75 | 75 | return $purchase['status'] = 'success'; |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | **/ |
| 84 | 84 | protected function buildHeaders() |
| 85 | 85 | { |
| 86 | - $headers = [ |
|
| 86 | + $headers = [ |
|
| 87 | 87 | 'Content-type' => 'application/json', |
| 88 | 88 | 'Authorization' => 'Bearer '.$this->bearer |
| 89 | 89 | ]; |
@@ -43,17 +43,17 @@ discard block |
||
| 43 | 43 | public function getPurchaseData( $code ) |
| 44 | 44 | { |
| 45 | 45 | $ch_verify = curl_init( $this->url. $code ); |
| 46 | - curl_setopt( $ch_verify, CURLOPT_HTTPHEADER, $this->headers ); |
|
| 47 | - curl_setopt( $ch_verify, CURLOPT_SSL_VERIFYPEER, false ); |
|
| 48 | - curl_setopt( $ch_verify, CURLOPT_RETURNTRANSFER, 1 ); |
|
| 49 | - curl_setopt( $ch_verify, CURLOPT_CONNECTTIMEOUT, 5 ); |
|
| 50 | - curl_setopt( $ch_verify, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13'); |
|
| 46 | + curl_setopt( $ch_verify, CURLOPT_HTTPHEADER, $this->headers ); |
|
| 47 | + curl_setopt( $ch_verify, CURLOPT_SSL_VERIFYPEER, false ); |
|
| 48 | + curl_setopt( $ch_verify, CURLOPT_RETURNTRANSFER, 1 ); |
|
| 49 | + curl_setopt( $ch_verify, CURLOPT_CONNECTTIMEOUT, 5 ); |
|
| 50 | + curl_setopt( $ch_verify, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13'); |
|
| 51 | 51 | |
| 52 | - $cinit_verify_data = curl_exec( $ch_verify ); |
|
| 53 | - curl_close( $ch_verify ); |
|
| 52 | + $cinit_verify_data = curl_exec( $ch_verify ); |
|
| 53 | + curl_close( $ch_verify ); |
|
| 54 | 54 | |
| 55 | - if ($cinit_verify_data != "") |
|
| 56 | - return json_decode($cinit_verify_data, true); |
|
| 55 | + if ($cinit_verify_data != "") |
|
| 56 | + return json_decode($cinit_verify_data, true); |
|
| 57 | 57 | |
| 58 | 58 | return ['error' => 'exception', 'description' => 'A server error was encountered please notify us if you see this']; |
| 59 | 59 | |
@@ -68,11 +68,11 @@ discard block |
||
| 68 | 68 | public function verifyPurchase(string $code ) |
| 69 | 69 | { |
| 70 | 70 | $purchase = []; |
| 71 | - $purchase['response'] = (object) $this->getPurchaseData($code); |
|
| 72 | - if($purchase->error) |
|
| 73 | - return $purchase['status'] = 'error'; |
|
| 74 | - else |
|
| 75 | - return $purchase['status'] = 'success'; |
|
| 71 | + $purchase['response'] = (object) $this->getPurchaseData($code); |
|
| 72 | + if($purchase->error) |
|
| 73 | + return $purchase['status'] = 'error'; |
|
| 74 | + else |
|
| 75 | + return $purchase['status'] = 'success'; |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | /** |
@@ -83,8 +83,8 @@ discard block |
||
| 83 | 83 | **/ |
| 84 | 84 | protected function buildHeaders() |
| 85 | 85 | { |
| 86 | - $headers = [ |
|
| 87 | - 'Content-type' => 'application/json', |
|
| 86 | + $headers = [ |
|
| 87 | + 'Content-type' => 'application/json', |
|
| 88 | 88 | 'Authorization' => 'Bearer '.$this->bearer |
| 89 | 89 | ]; |
| 90 | 90 | $h = []; |
@@ -52,8 +52,9 @@ discard block |
||
| 52 | 52 | $cinit_verify_data = curl_exec( $ch_verify ); |
| 53 | 53 | curl_close( $ch_verify ); |
| 54 | 54 | |
| 55 | - if ($cinit_verify_data != "") |
|
| 56 | - return json_decode($cinit_verify_data, true); |
|
| 55 | + if ($cinit_verify_data != "") { |
|
| 56 | + return json_decode($cinit_verify_data, true); |
|
| 57 | + } |
|
| 57 | 58 | |
| 58 | 59 | return ['error' => 'exception', 'description' => 'A server error was encountered please notify us if you see this']; |
| 59 | 60 | |
@@ -69,10 +70,11 @@ discard block |
||
| 69 | 70 | { |
| 70 | 71 | $purchase = []; |
| 71 | 72 | $purchase['response'] = (object) $this->getPurchaseData($code); |
| 72 | - if($purchase->error) |
|
| 73 | - return $purchase['status'] = 'error'; |
|
| 74 | - else |
|
| 75 | - return $purchase['status'] = 'success'; |
|
| 73 | + if($purchase->error) { |
|
| 74 | + return $purchase['status'] = 'error'; |
|
| 75 | + } else { |
|
| 76 | + return $purchase['status'] = 'success'; |
|
| 77 | + } |
|
| 76 | 78 | } |
| 77 | 79 | |
| 78 | 80 | /** |
@@ -5,38 +5,38 @@ |
||
| 5 | 5 | |
| 6 | 6 | class LicenseChecker |
| 7 | 7 | { |
| 8 | - /** |
|
| 9 | - * Handle an incoming request. |
|
| 10 | - * |
|
| 11 | - * @param \Illuminate\Http\Request $request |
|
| 12 | - * @param \Closure $next |
|
| 13 | - * @return mixed |
|
| 14 | - */ |
|
| 15 | - public function handle($request, Closure $next, $licenseKey = null) |
|
| 16 | - { |
|
| 8 | + /** |
|
| 9 | + * Handle an incoming request. |
|
| 10 | + * |
|
| 11 | + * @param \Illuminate\Http\Request $request |
|
| 12 | + * @param \Closure $next |
|
| 13 | + * @return mixed |
|
| 14 | + */ |
|
| 15 | + public function handle($request, Closure $next, $licenseKey = null) |
|
| 16 | + { |
|
| 17 | 17 | |
| 18 | - if($this->validLicense($licenseKey)){ |
|
| 19 | - return $next($request); |
|
| 20 | - } |
|
| 21 | - else{ |
|
| 22 | - return response()->json(['UnAuthorized' => 'Invalid Purchase Key'],403); |
|
| 23 | - } |
|
| 18 | + if($this->validLicense($licenseKey)){ |
|
| 19 | + return $next($request); |
|
| 20 | + } |
|
| 21 | + else{ |
|
| 22 | + return response()->json(['UnAuthorized' => 'Invalid Purchase Key'],403); |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | - } |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * Check if license key is valid |
|
| 29 | - * |
|
| 30 | - * @return boolean |
|
| 31 | - **/ |
|
| 32 | - private function validLicense($licenseKey) |
|
| 33 | - { |
|
| 27 | + /** |
|
| 28 | + * Check if license key is valid |
|
| 29 | + * |
|
| 30 | + * @return boolean |
|
| 31 | + **/ |
|
| 32 | + private function validLicense($licenseKey) |
|
| 33 | + { |
|
| 34 | 34 | |
| 35 | - $purchase = app()->envatoapi->verifyPurchase($licenseKey ); |
|
| 36 | - if ( is_array($purchase) and $purchase['status'] == 'success') { |
|
| 37 | - return true; |
|
| 38 | - } |
|
| 39 | - return false; |
|
| 35 | + $purchase = app()->envatoapi->verifyPurchase($licenseKey ); |
|
| 36 | + if ( is_array($purchase) and $purchase['status'] == 'success') { |
|
| 37 | + return true; |
|
| 38 | + } |
|
| 39 | + return false; |
|
| 40 | 40 | |
| 41 | - } |
|
| 41 | + } |
|
| 42 | 42 | |
@@ -15,11 +15,11 @@ discard block |
||
| 15 | 15 | public function handle($request, Closure $next, $licenseKey = null) |
| 16 | 16 | { |
| 17 | 17 | |
| 18 | - if($this->validLicense($licenseKey)){ |
|
| 18 | + if ($this->validLicense($licenseKey)) { |
|
| 19 | 19 | return $next($request); |
| 20 | 20 | } |
| 21 | - else{ |
|
| 22 | - return response()->json(['UnAuthorized' => 'Invalid Purchase Key'],403); |
|
| 21 | + else { |
|
| 22 | + return response()->json(['UnAuthorized' => 'Invalid Purchase Key'], 403); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | } |
@@ -32,8 +32,8 @@ discard block |
||
| 32 | 32 | private function validLicense($licenseKey) |
| 33 | 33 | { |
| 34 | 34 | |
| 35 | - $purchase = app()->envatoapi->verifyPurchase($licenseKey ); |
|
| 36 | - if ( is_array($purchase) and $purchase['status'] == 'success') { |
|
| 35 | + $purchase = app()->envatoapi->verifyPurchase($licenseKey); |
|
| 36 | + if (is_array($purchase) and $purchase['status'] == 'success') { |
|
| 37 | 37 | return true; |
| 38 | 38 | } |
| 39 | 39 | return false; |
@@ -17,8 +17,7 @@ |
||
| 17 | 17 | |
| 18 | 18 | if($this->validLicense($licenseKey)){ |
| 19 | 19 | return $next($request); |
| 20 | - } |
|
| 21 | - else{ |
|
| 20 | + } else{ |
|
| 22 | 21 | return response()->json(['UnAuthorized' => 'Invalid Purchase Key'],403); |
| 23 | 22 | } |
| 24 | 23 | |