@@ -2,5 +2,5 @@ |
||
2 | 2 | /** |
3 | 3 | * Application update routes. |
4 | 4 | **/ |
5 | -Route::group(['prefix' => 'updates', 'namespace' => 'Elimuswift\\Core\\Controllers'], function () { |
|
5 | +Route::group(['prefix' => 'updates', 'namespace' => 'Elimuswift\\Core\\Controllers'], function() { |
|
6 | 6 | }); |
@@ -6,37 +6,37 @@ |
||
6 | 6 | |
7 | 7 | class CreateUpdatesTable extends Migration |
8 | 8 | { |
9 | - /** |
|
10 | - * Run the migrations. |
|
11 | - */ |
|
12 | - public function up() |
|
13 | - { |
|
14 | - Schema::create('updates', function (Blueprint $table) { |
|
15 | - $table->increments('id'); |
|
16 | - $table->string('title'); |
|
17 | - $table->string('version', 10); |
|
18 | - $table->string('type'); |
|
19 | - $table->text('description'); |
|
20 | - $table->integer('downloads'); |
|
21 | - $table->timestamps(); |
|
22 | - }); |
|
9 | + /** |
|
10 | + * Run the migrations. |
|
11 | + */ |
|
12 | + public function up() |
|
13 | + { |
|
14 | + Schema::create('updates', function (Blueprint $table) { |
|
15 | + $table->increments('id'); |
|
16 | + $table->string('title'); |
|
17 | + $table->string('version', 10); |
|
18 | + $table->string('type'); |
|
19 | + $table->text('description'); |
|
20 | + $table->integer('downloads'); |
|
21 | + $table->timestamps(); |
|
22 | + }); |
|
23 | 23 | |
24 | - Schema::create('customers', function (Blueprint $table) { |
|
25 | - $table->increments('id'); |
|
26 | - $table->string('name'); |
|
27 | - $table->string('purchaseKey'); |
|
28 | - $table->timestamp('support_ends'); |
|
29 | - $table->string('email')->unique(); |
|
30 | - $table->timestamps(); |
|
31 | - }); |
|
32 | - } |
|
24 | + Schema::create('customers', function (Blueprint $table) { |
|
25 | + $table->increments('id'); |
|
26 | + $table->string('name'); |
|
27 | + $table->string('purchaseKey'); |
|
28 | + $table->timestamp('support_ends'); |
|
29 | + $table->string('email')->unique(); |
|
30 | + $table->timestamps(); |
|
31 | + }); |
|
32 | + } |
|
33 | 33 | |
34 | - /** |
|
35 | - * Reverse the migrations. |
|
36 | - */ |
|
37 | - public function down() |
|
38 | - { |
|
39 | - Schema::dropIfExists('customers'); |
|
40 | - Schema::dropIfExists('updates'); |
|
41 | - } |
|
34 | + /** |
|
35 | + * Reverse the migrations. |
|
36 | + */ |
|
37 | + public function down() |
|
38 | + { |
|
39 | + Schema::dropIfExists('customers'); |
|
40 | + Schema::dropIfExists('updates'); |
|
41 | + } |
|
42 | 42 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | public function up() |
13 | 13 | { |
14 | - Schema::create('updates', function (Blueprint $table) { |
|
14 | + Schema::create('updates', function(Blueprint $table) { |
|
15 | 15 | $table->increments('id'); |
16 | 16 | $table->string('title'); |
17 | 17 | $table->string('version', 10); |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | $table->timestamps(); |
22 | 22 | }); |
23 | 23 | |
24 | - Schema::create('customers', function (Blueprint $table) { |
|
24 | + Schema::create('customers', function(Blueprint $table) { |
|
25 | 25 | $table->increments('id'); |
26 | 26 | $table->string('name'); |
27 | 27 | $table->string('purchaseKey'); |
@@ -6,51 +6,51 @@ |
||
6 | 6 | |
7 | 7 | class ElimuswiftCoreServiceProvider extends ServiceProvider |
8 | 8 | { |
9 | - /** |
|
10 | - * Bootstrap the application services. |
|
11 | - */ |
|
12 | - public function boot() |
|
13 | - { |
|
14 | - $this->loadFiles(); |
|
15 | - } |
|
9 | + /** |
|
10 | + * Bootstrap the application services. |
|
11 | + */ |
|
12 | + public function boot() |
|
13 | + { |
|
14 | + $this->loadFiles(); |
|
15 | + } |
|
16 | 16 | |
17 | 17 | //end boot() |
18 | 18 | |
19 | - /** |
|
20 | - * Register the application services. |
|
21 | - */ |
|
22 | - public function register() |
|
23 | - { |
|
24 | - $this->mergeConfigFrom( |
|
25 | - __DIR__ . '/config/core.php', |
|
26 | - 'core' |
|
27 | - ); |
|
28 | - |
|
29 | - $this->app->singleton( |
|
30 | - 'envatoapi', |
|
31 | - function () { |
|
32 | - return new EnvatoApi(env('ENVATO_SECRET')); |
|
33 | - } |
|
34 | - ); |
|
35 | - |
|
36 | - $this->app->bind('Elimuswift\Core\Repositories\Contracts\RepositoryContract', 'Elimuswift\Core\Repositories\UpdatesRepository'); |
|
37 | - } |
|
19 | + /** |
|
20 | + * Register the application services. |
|
21 | + */ |
|
22 | + public function register() |
|
23 | + { |
|
24 | + $this->mergeConfigFrom( |
|
25 | + __DIR__ . '/config/core.php', |
|
26 | + 'core' |
|
27 | + ); |
|
28 | + |
|
29 | + $this->app->singleton( |
|
30 | + 'envatoapi', |
|
31 | + function () { |
|
32 | + return new EnvatoApi(env('ENVATO_SECRET')); |
|
33 | + } |
|
34 | + ); |
|
35 | + |
|
36 | + $this->app->bind('Elimuswift\Core\Repositories\Contracts\RepositoryContract', 'Elimuswift\Core\Repositories\UpdatesRepository'); |
|
37 | + } |
|
38 | 38 | |
39 | 39 | //end register() |
40 | 40 | |
41 | - /** |
|
42 | - * Load and publish app migration files. |
|
43 | - **/ |
|
44 | - protected function loadFiles() |
|
45 | - { |
|
46 | - $this->publishes( |
|
47 | - [ |
|
48 | - __DIR__ . 'config/core.php' => config_path('core.php'), |
|
49 | - ] |
|
50 | - ); |
|
51 | - // $this->loadMigrationsFrom(__DIR__.'/Migrations'); |
|
52 | - $this->loadRoutesFrom(__DIR__ . '/routes.php'); |
|
53 | - } |
|
41 | + /** |
|
42 | + * Load and publish app migration files. |
|
43 | + **/ |
|
44 | + protected function loadFiles() |
|
45 | + { |
|
46 | + $this->publishes( |
|
47 | + [ |
|
48 | + __DIR__ . 'config/core.php' => config_path('core.php'), |
|
49 | + ] |
|
50 | + ); |
|
51 | + // $this->loadMigrationsFrom(__DIR__.'/Migrations'); |
|
52 | + $this->loadRoutesFrom(__DIR__ . '/routes.php'); |
|
53 | + } |
|
54 | 54 | |
55 | 55 | //end loadFiles() |
56 | 56 | }//end class |
@@ -22,13 +22,13 @@ discard block |
||
22 | 22 | public function register() |
23 | 23 | { |
24 | 24 | $this->mergeConfigFrom( |
25 | - __DIR__ . '/config/core.php', |
|
25 | + __DIR__.'/config/core.php', |
|
26 | 26 | 'core' |
27 | 27 | ); |
28 | 28 | |
29 | 29 | $this->app->singleton( |
30 | 30 | 'envatoapi', |
31 | - function () { |
|
31 | + function() { |
|
32 | 32 | return new EnvatoApi(env('ENVATO_SECRET')); |
33 | 33 | } |
34 | 34 | ); |
@@ -45,11 +45,11 @@ discard block |
||
45 | 45 | { |
46 | 46 | $this->publishes( |
47 | 47 | [ |
48 | - __DIR__ . 'config/core.php' => config_path('core.php'), |
|
48 | + __DIR__.'config/core.php' => config_path('core.php'), |
|
49 | 49 | ] |
50 | 50 | ); |
51 | 51 | // $this->loadMigrationsFrom(__DIR__.'/Migrations'); |
52 | - $this->loadRoutesFrom(__DIR__ . '/routes.php'); |
|
52 | + $this->loadRoutesFrom(__DIR__.'/routes.php'); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | //end loadFiles() |
@@ -7,15 +7,15 @@ |
||
7 | 7 | */ |
8 | 8 | class FilesystemRepository |
9 | 9 | { |
10 | - /** |
|
11 | - * Get a specific update version. |
|
12 | - * |
|
13 | - * @return object Illuminate\Filesystem\Filesystem instance |
|
14 | - * |
|
15 | - * @param string $version Build version |
|
16 | - **/ |
|
17 | - public function getRelease($version) |
|
18 | - { |
|
19 | - return \Storage::get("updates/update_{$version}.zip"); |
|
20 | - } |
|
10 | + /** |
|
11 | + * Get a specific update version. |
|
12 | + * |
|
13 | + * @return object Illuminate\Filesystem\Filesystem instance |
|
14 | + * |
|
15 | + * @param string $version Build version |
|
16 | + **/ |
|
17 | + public function getRelease($version) |
|
18 | + { |
|
19 | + return \Storage::get("updates/update_{$version}.zip"); |
|
20 | + } |
|
21 | 21 | } |
@@ -7,37 +7,37 @@ |
||
7 | 7 | */ |
8 | 8 | interface RepositoryContract |
9 | 9 | { |
10 | - /** |
|
11 | - * Return all the available releses. |
|
12 | - * |
|
13 | - * @return mixed Illuminate\Support\Collection |
|
14 | - **/ |
|
15 | - public function releases(); |
|
10 | + /** |
|
11 | + * Return all the available releses. |
|
12 | + * |
|
13 | + * @return mixed Illuminate\Support\Collection |
|
14 | + **/ |
|
15 | + public function releases(); |
|
16 | 16 | |
17 | - /** |
|
18 | - * Get a specific update version. |
|
19 | - * |
|
20 | - * @return object Elimuswift\Core\Update instance |
|
21 | - * @return object Illuminate\Filesystem\Filesystem |
|
22 | - * |
|
23 | - * @param string $version Build version |
|
24 | - **/ |
|
25 | - public function getRelease($version); |
|
17 | + /** |
|
18 | + * Get a specific update version. |
|
19 | + * |
|
20 | + * @return object Elimuswift\Core\Update instance |
|
21 | + * @return object Illuminate\Filesystem\Filesystem |
|
22 | + * |
|
23 | + * @param string $version Build version |
|
24 | + **/ |
|
25 | + public function getRelease($version); |
|
26 | 26 | |
27 | - /** |
|
28 | - * Get releases later than the provided $version. |
|
29 | - * |
|
30 | - * @return object Illuminate\Support\Collection |
|
31 | - * |
|
32 | - * @param string $version Version to compare |
|
33 | - **/ |
|
34 | - public function laterThan($version); |
|
27 | + /** |
|
28 | + * Get releases later than the provided $version. |
|
29 | + * |
|
30 | + * @return object Illuminate\Support\Collection |
|
31 | + * |
|
32 | + * @param string $version Version to compare |
|
33 | + **/ |
|
34 | + public function laterThan($version); |
|
35 | 35 | |
36 | - /** |
|
37 | - * Get the latest update version. |
|
38 | - * |
|
39 | - * @return object Elimuswift\Core\Update instance |
|
40 | - * @return object Illuminate\Filesystem\Filesystem |
|
41 | - **/ |
|
42 | - public function latest(); |
|
36 | + /** |
|
37 | + * Get the latest update version. |
|
38 | + * |
|
39 | + * @return object Elimuswift\Core\Update instance |
|
40 | + * @return object Illuminate\Filesystem\Filesystem |
|
41 | + **/ |
|
42 | + public function latest(); |
|
43 | 43 | } |
@@ -9,75 +9,75 @@ |
||
9 | 9 | */ |
10 | 10 | class UpdatesRepository implements Contracts\RepositoryContract |
11 | 11 | { |
12 | - /** |
|
13 | - * Update Model instance. |
|
14 | - * |
|
15 | - * @var mixed |
|
16 | - **/ |
|
17 | - public $updates; |
|
12 | + /** |
|
13 | + * Update Model instance. |
|
14 | + * |
|
15 | + * @var mixed |
|
16 | + **/ |
|
17 | + public $updates; |
|
18 | 18 | |
19 | - /** |
|
20 | - * Create a new instance of the UpdatesManager::class. |
|
21 | - **/ |
|
22 | - public function __construct(Update $update) |
|
23 | - { |
|
24 | - $this->updates = $update; |
|
25 | - } |
|
19 | + /** |
|
20 | + * Create a new instance of the UpdatesManager::class. |
|
21 | + **/ |
|
22 | + public function __construct(Update $update) |
|
23 | + { |
|
24 | + $this->updates = $update; |
|
25 | + } |
|
26 | 26 | |
27 | - /** |
|
28 | - * Return all the available releses. |
|
29 | - * |
|
30 | - * @return mixed Illuminate\Support\Collection |
|
31 | - **/ |
|
32 | - public function releases() |
|
33 | - { |
|
34 | - return $this->updates->all(); |
|
35 | - } |
|
27 | + /** |
|
28 | + * Return all the available releses. |
|
29 | + * |
|
30 | + * @return mixed Illuminate\Support\Collection |
|
31 | + **/ |
|
32 | + public function releases() |
|
33 | + { |
|
34 | + return $this->updates->all(); |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * Get a specific update version. |
|
39 | - * |
|
40 | - * @return object Elimuswift\Core\Update instance |
|
41 | - * |
|
42 | - * @param string $version Build version |
|
43 | - **/ |
|
44 | - public function getRelease($version) |
|
45 | - { |
|
46 | - return $this->updates->whereVersion($version)->first(); |
|
47 | - } |
|
37 | + /** |
|
38 | + * Get a specific update version. |
|
39 | + * |
|
40 | + * @return object Elimuswift\Core\Update instance |
|
41 | + * |
|
42 | + * @param string $version Build version |
|
43 | + **/ |
|
44 | + public function getRelease($version) |
|
45 | + { |
|
46 | + return $this->updates->whereVersion($version)->first(); |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * Get releases later than the provided $version. |
|
51 | - * |
|
52 | - * @return object Illuminate\Support\Collection |
|
53 | - * |
|
54 | - * @param string $version Version to compare |
|
55 | - **/ |
|
56 | - public function laterThan($version) |
|
57 | - { |
|
58 | - return $this->updates->where('version', '>', $version)->get(); |
|
59 | - } |
|
49 | + /** |
|
50 | + * Get releases later than the provided $version. |
|
51 | + * |
|
52 | + * @return object Illuminate\Support\Collection |
|
53 | + * |
|
54 | + * @param string $version Version to compare |
|
55 | + **/ |
|
56 | + public function laterThan($version) |
|
57 | + { |
|
58 | + return $this->updates->where('version', '>', $version)->get(); |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * Get the latest update version. |
|
63 | - * |
|
64 | - * @return object Elimuswift\Core\Update instance |
|
65 | - **/ |
|
66 | - public function latest() |
|
67 | - { |
|
68 | - return $this->updates->orderBy('version', 'DESC')->first(); |
|
69 | - } |
|
61 | + /** |
|
62 | + * Get the latest update version. |
|
63 | + * |
|
64 | + * @return object Elimuswift\Core\Update instance |
|
65 | + **/ |
|
66 | + public function latest() |
|
67 | + { |
|
68 | + return $this->updates->orderBy('version', 'DESC')->first(); |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * Get config properties. |
|
73 | - * |
|
74 | - * @return mixed |
|
75 | - **/ |
|
76 | - public function config($property) |
|
77 | - { |
|
78 | - if (config()->has("core.{$property}")) { |
|
79 | - return config()->get("core.{$property}"); |
|
80 | - } |
|
81 | - throw new \Exception("Property {$property} does not exist", 1); |
|
82 | - } |
|
71 | + /** |
|
72 | + * Get config properties. |
|
73 | + * |
|
74 | + * @return mixed |
|
75 | + **/ |
|
76 | + public function config($property) |
|
77 | + { |
|
78 | + if (config()->has("core.{$property}")) { |
|
79 | + return config()->get("core.{$property}"); |
|
80 | + } |
|
81 | + throw new \Exception("Property {$property} does not exist", 1); |
|
82 | + } |
|
83 | 83 | } |
@@ -1,7 +1,7 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | return [ |
4 | - 'updates' => [ |
|
5 | - 'updatesPath' => storage_path('updates'), |
|
6 | - ], |
|
4 | + 'updates' => [ |
|
5 | + 'updatesPath' => storage_path('updates'), |
|
6 | + ], |
|
7 | 7 | ]; |
@@ -4,105 +4,105 @@ |
||
4 | 4 | |
5 | 5 | class EnvatoApi |
6 | 6 | { |
7 | - /** |
|
8 | - * Envanto API bearer token. |
|
9 | - * |
|
10 | - * @var string |
|
11 | - **/ |
|
12 | - private $bearer; |
|
13 | - |
|
14 | - /** |
|
15 | - * Purchase verification endpoint. |
|
16 | - * |
|
17 | - * @var string |
|
18 | - **/ |
|
19 | - protected $url = 'https://api.envato.com/v3/market/author/sale?code='; |
|
20 | - |
|
21 | - /** |
|
22 | - * Request headers. |
|
23 | - * |
|
24 | - * @var array |
|
25 | - **/ |
|
26 | - private $headers; |
|
27 | - |
|
28 | - /** |
|
29 | - * Create EnvantoApi Instance. |
|
30 | - **/ |
|
31 | - public function __construct($bearer) |
|
32 | - { |
|
33 | - $this->bearer = $bearer; |
|
34 | - $this->buildHeaders(); |
|
35 | - } |
|
7 | + /** |
|
8 | + * Envanto API bearer token. |
|
9 | + * |
|
10 | + * @var string |
|
11 | + **/ |
|
12 | + private $bearer; |
|
13 | + |
|
14 | + /** |
|
15 | + * Purchase verification endpoint. |
|
16 | + * |
|
17 | + * @var string |
|
18 | + **/ |
|
19 | + protected $url = 'https://api.envato.com/v3/market/author/sale?code='; |
|
20 | + |
|
21 | + /** |
|
22 | + * Request headers. |
|
23 | + * |
|
24 | + * @var array |
|
25 | + **/ |
|
26 | + private $headers; |
|
27 | + |
|
28 | + /** |
|
29 | + * Create EnvantoApi Instance. |
|
30 | + **/ |
|
31 | + public function __construct($bearer) |
|
32 | + { |
|
33 | + $this->bearer = $bearer; |
|
34 | + $this->buildHeaders(); |
|
35 | + } |
|
36 | 36 | |
37 | 37 | //end __construct() |
38 | 38 | |
39 | - /** |
|
40 | - * Make a call to the Envato API to verify purchase. |
|
41 | - * |
|
42 | - * @return mixed Guzzle\Response::getBody() |
|
43 | - * |
|
44 | - * @param string $code |
|
45 | - **/ |
|
46 | - public function getPurchaseData($code) |
|
47 | - { |
|
48 | - $ch_verify = curl_init($this->url . $code); |
|
49 | - curl_setopt($ch_verify, CURLOPT_HTTPHEADER, $this->headers); |
|
50 | - curl_setopt($ch_verify, CURLOPT_SSL_VERIFYPEER, false); |
|
51 | - curl_setopt($ch_verify, CURLOPT_RETURNTRANSFER, 1); |
|
52 | - curl_setopt($ch_verify, CURLOPT_CONNECTTIMEOUT, 5); |
|
53 | - 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'); |
|
54 | - |
|
55 | - $cinit_verify_data = curl_exec($ch_verify); |
|
56 | - curl_close($ch_verify); |
|
57 | - |
|
58 | - if ($cinit_verify_data != '') { |
|
59 | - return json_decode($cinit_verify_data, true); |
|
60 | - } |
|
61 | - |
|
62 | - return [ |
|
63 | - 'error' => 'exception', |
|
64 | - 'description' => 'A server error was encountered please notify us if you see this', |
|
65 | - ]; |
|
66 | - } |
|
39 | + /** |
|
40 | + * Make a call to the Envato API to verify purchase. |
|
41 | + * |
|
42 | + * @return mixed Guzzle\Response::getBody() |
|
43 | + * |
|
44 | + * @param string $code |
|
45 | + **/ |
|
46 | + public function getPurchaseData($code) |
|
47 | + { |
|
48 | + $ch_verify = curl_init($this->url . $code); |
|
49 | + curl_setopt($ch_verify, CURLOPT_HTTPHEADER, $this->headers); |
|
50 | + curl_setopt($ch_verify, CURLOPT_SSL_VERIFYPEER, false); |
|
51 | + curl_setopt($ch_verify, CURLOPT_RETURNTRANSFER, 1); |
|
52 | + curl_setopt($ch_verify, CURLOPT_CONNECTTIMEOUT, 5); |
|
53 | + 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'); |
|
54 | + |
|
55 | + $cinit_verify_data = curl_exec($ch_verify); |
|
56 | + curl_close($ch_verify); |
|
57 | + |
|
58 | + if ($cinit_verify_data != '') { |
|
59 | + return json_decode($cinit_verify_data, true); |
|
60 | + } |
|
61 | + |
|
62 | + return [ |
|
63 | + 'error' => 'exception', |
|
64 | + 'description' => 'A server error was encountered please notify us if you see this', |
|
65 | + ]; |
|
66 | + } |
|
67 | 67 | |
68 | 68 | //end getPurchaseData() |
69 | 69 | |
70 | - /** |
|
71 | - * Verify purchase. |
|
72 | - * |
|
73 | - * @return string Array |
|
74 | - * |
|
75 | - * @param string $code Purchase Code |
|
76 | - **/ |
|
77 | - public function verifyPurchase(string $code) |
|
78 | - { |
|
79 | - $purchase = []; |
|
80 | - $purchase['response'] = (object) $this->getPurchaseData($code); |
|
81 | - if ($purchase->error) { |
|
82 | - return $purchase['status'] = 'error'; |
|
83 | - } else { |
|
84 | - return $purchase['status'] = 'success'; |
|
85 | - } |
|
86 | - } |
|
70 | + /** |
|
71 | + * Verify purchase. |
|
72 | + * |
|
73 | + * @return string Array |
|
74 | + * |
|
75 | + * @param string $code Purchase Code |
|
76 | + **/ |
|
77 | + public function verifyPurchase(string $code) |
|
78 | + { |
|
79 | + $purchase = []; |
|
80 | + $purchase['response'] = (object) $this->getPurchaseData($code); |
|
81 | + if ($purchase->error) { |
|
82 | + return $purchase['status'] = 'error'; |
|
83 | + } else { |
|
84 | + return $purchase['status'] = 'success'; |
|
85 | + } |
|
86 | + } |
|
87 | 87 | |
88 | 88 | //end verifyPurchase() |
89 | 89 | |
90 | - /** |
|
91 | - * setting the header for the rest of the api. |
|
92 | - **/ |
|
93 | - protected function buildHeaders() |
|
94 | - { |
|
95 | - $headers = [ |
|
96 | - 'Content-type' => 'application/json', |
|
97 | - 'Authorization' => 'Bearer ' . $this->bearer, |
|
98 | - ]; |
|
99 | - $h = []; |
|
100 | - foreach ($headers as $key => $value) { |
|
101 | - $h[] = $key . ':' . $value; |
|
102 | - } |
|
103 | - |
|
104 | - $this->headers = $h; |
|
105 | - } |
|
90 | + /** |
|
91 | + * setting the header for the rest of the api. |
|
92 | + **/ |
|
93 | + protected function buildHeaders() |
|
94 | + { |
|
95 | + $headers = [ |
|
96 | + 'Content-type' => 'application/json', |
|
97 | + 'Authorization' => 'Bearer ' . $this->bearer, |
|
98 | + ]; |
|
99 | + $h = []; |
|
100 | + foreach ($headers as $key => $value) { |
|
101 | + $h[] = $key . ':' . $value; |
|
102 | + } |
|
103 | + |
|
104 | + $this->headers = $h; |
|
105 | + } |
|
106 | 106 | |
107 | 107 | //end buildHeaders() |
108 | 108 | }//end class |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | **/ |
46 | 46 | public function getPurchaseData($code) |
47 | 47 | { |
48 | - $ch_verify = curl_init($this->url . $code); |
|
48 | + $ch_verify = curl_init($this->url.$code); |
|
49 | 49 | curl_setopt($ch_verify, CURLOPT_HTTPHEADER, $this->headers); |
50 | 50 | curl_setopt($ch_verify, CURLOPT_SSL_VERIFYPEER, false); |
51 | 51 | curl_setopt($ch_verify, CURLOPT_RETURNTRANSFER, 1); |
@@ -94,11 +94,11 @@ discard block |
||
94 | 94 | { |
95 | 95 | $headers = [ |
96 | 96 | 'Content-type' => 'application/json', |
97 | - 'Authorization' => 'Bearer ' . $this->bearer, |
|
97 | + 'Authorization' => 'Bearer '.$this->bearer, |
|
98 | 98 | ]; |
99 | 99 | $h = []; |
100 | 100 | foreach ($headers as $key => $value) { |
101 | - $h[] = $key . ':' . $value; |
|
101 | + $h[] = $key.':'.$value; |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | $this->headers = $h; |
@@ -6,35 +6,35 @@ |
||
6 | 6 | |
7 | 7 | class LicenseChecker |
8 | 8 | { |
9 | - /** |
|
10 | - * Handle an incoming request. |
|
11 | - * |
|
12 | - * @param \Illuminate\Http\Request $request |
|
13 | - * @param \Closure $next |
|
14 | - * |
|
15 | - * @return mixed |
|
16 | - */ |
|
17 | - public function handle($request, Closure $next, $licenseKey = null) |
|
18 | - { |
|
19 | - if ($this->validLicense($licenseKey)) { |
|
20 | - return $next($request); |
|
21 | - } else { |
|
22 | - return response()->json(['UnAuthorized' => 'Invalid Purchase Key'], 403); |
|
23 | - } |
|
24 | - } |
|
9 | + /** |
|
10 | + * Handle an incoming request. |
|
11 | + * |
|
12 | + * @param \Illuminate\Http\Request $request |
|
13 | + * @param \Closure $next |
|
14 | + * |
|
15 | + * @return mixed |
|
16 | + */ |
|
17 | + public function handle($request, Closure $next, $licenseKey = null) |
|
18 | + { |
|
19 | + if ($this->validLicense($licenseKey)) { |
|
20 | + return $next($request); |
|
21 | + } else { |
|
22 | + return response()->json(['UnAuthorized' => 'Invalid Purchase Key'], 403); |
|
23 | + } |
|
24 | + } |
|
25 | 25 | |
26 | - /** |
|
27 | - * Check if license key is valid. |
|
28 | - * |
|
29 | - * @return bool |
|
30 | - **/ |
|
31 | - private function validLicense($licenseKey) |
|
32 | - { |
|
33 | - $purchase = app()->envatoapi->verifyPurchase($licenseKey); |
|
34 | - if (is_array($purchase) and $purchase['status'] == 'success') { |
|
35 | - return true; |
|
36 | - } |
|
26 | + /** |
|
27 | + * Check if license key is valid. |
|
28 | + * |
|
29 | + * @return bool |
|
30 | + **/ |
|
31 | + private function validLicense($licenseKey) |
|
32 | + { |
|
33 | + $purchase = app()->envatoapi->verifyPurchase($licenseKey); |
|
34 | + if (is_array($purchase) and $purchase['status'] == 'success') { |
|
35 | + return true; |
|
36 | + } |
|
37 | 37 | |
38 | - return false; |
|
39 | - } |
|
38 | + return false; |
|
39 | + } |
|
40 | 40 | } |