diff --git a/.env.example b/.env.example index cd249c6..81c4abf 100644 --- a/.env.example +++ b/.env.example @@ -14,9 +14,12 @@ DB_USERNAME=root DB_PASSWORD= BROADCAST_DRIVER=log -CACHE_DRIVER=file +CACHE_DRIVER=redis + QUEUE_CONNECTION=sync -SESSION_DRIVER=file +QUEUE_DRIVER=redis + +SESSION_DRIVER=redis SESSION_LIFETIME=120 REDIS_HOST=127.0.0.1 diff --git a/app/Http/Controllers/Dashboard/DashboardController.php b/app/Http/Controllers/Dashboard/DashboardController.php index 5ff2766..0b9a34c 100644 --- a/app/Http/Controllers/Dashboard/DashboardController.php +++ b/app/Http/Controllers/Dashboard/DashboardController.php @@ -4,13 +4,21 @@ namespace App\Http\Controllers\Dashboard; use Illuminate\Http\Request; +//Library +use App\Library\Contracts\ContractHelper; + class DashboardController extends Controller { public function __construct() { - $this->middleware('role:Uesr'); + $this->middleware('role:User'); } public function index() { + + + //Get the current amount of contracts availabe to the corporation for displaying on the dashboard with the relevant + //information such as pickup and destination, jumps, and profit margin. + return redirect('/'); } diff --git a/app/Jobs/ProcessSendEveMailJob.php b/app/Jobs/ProcessSendEveMailJob.php new file mode 100644 index 0000000..d88bfe2 --- /dev/null +++ b/app/Jobs/ProcessSendEveMailJob.php @@ -0,0 +1,115 @@ +body = $mail->body; + $this->recipient = $mail->recipient; + $this->recipient_type = $mail->recipient_type; + $this->subject = $mail->subject; + + $this->connection = 'redis'; + } + + /** + * Execute the job. + * Utilized by using ProcessSendEveMailJob::dispatch($mail); + * The model is passed into the dispatch function, then added to the queue + * for processing. + * + * @return void + */ + public function handle() + { + //Get the esi configuration + $config = config('esi'); + + //Declare the esi helper + $esiHelper = new Esi; + + //Get the refresh token + $token = $esiHelper->GetRefreshToken($config['primary']); + //Setup the authentication container + $esi = $esiHelper->SetupEsiAuthentication($token); + + //Attemp to send the mail + try { + $esi->setBody([ + 'approved_cost' => 100, + 'body' => $this->body, + 'recipients' => [[ + 'recipient_id' => $this->recipient, + 'recipient_type' => $this->recipient_type, + ]], + 'subject' => $this->subject, + ])->invoke('post', '/characters/{character_id}/mail/', [ + 'character_id'=> $config['primary'], + ]); + } catch(RequestFailedException $e) { + Log::warning($e); + return null; + } + + $this->delete(); + } + + /** + * The job failed to process. + * + * @param Exception $exception + * @return void + */ + public function failed($exception) + { + Log::critical($exception); + } +} + +?> diff --git a/app/Library/Contracts/ContractHelper.php b/app/Library/Contracts/ContractHelper.php new file mode 100644 index 0000000..0c0d8ec --- /dev/null +++ b/app/Library/Contracts/ContractHelper.php @@ -0,0 +1,50 @@ +cache = NullCache::class; + + //Get the refresh token from the database + $token = $esiHelper->GetRefreshToken($config['primary']); + $this->esi = $esiHelper->SetupEsiAuthentication($token); + } + + public function GetNumOfContracts() { + + } + + public function GetContractDetails($contract) { + + } +} + +?> diff --git a/app/Library/Esi/Esi.php b/app/Library/Esi/Esi.php index 2adeb99..5c406aa 100644 --- a/app/Library/Esi/Esi.php +++ b/app/Library/Esi/Esi.php @@ -43,86 +43,6 @@ class Esi { } } - public function GetCharacterData($charId) { - $esi = new Eseye(); - try { - $character = $esi->invoke('get', '/characters/{character_id}/', [ - 'character_id' => $charId, - ]); - } catch(RequestFailedException $e) { - return null; - } - - return $character; - } - - public function GetCharacterName($charId) { - $esi = new Eseye(); - try { - $character = $esi->invoke('get', '/characters/{character_id}/', [ - 'character_id' => $charId, - ]); - } catch(RequestFailedException $e) { - return null; - } - - return $character->name; - } - - public function FindCharacterId($name) { - $config = config('esi'); - //Create the esi authentication container - $authentication = new EsiAuthentication([ - 'client_id' => $config['client_id'], - 'secret' => $config['secret'], - ]); - //Create the esi container - $esi = new Eseye($authentication); - try { - $character = $esi->setQueryString([ - 'categories' => 'character', - 'language' => 'en-us', - 'search' => $name, - 'strict' => 'true', - ])->invoke('get', '/search/'); - } catch(RequestFailedException $e) { - return null; - } - - $character = json_decode($character, true); - return $character['character']; - } - - public function FindCorporationId($charId) { - $esi = new Eseye(); - try { - $character = $esi->invoke('get', '/characters/{character_id}/', [ - 'character_id' => $charId, - ]); - } catch(RequestFailedException $e) { - return null; - } - - return $character->corporation_id; - } - - public function FindCorporationName($charId) { - $esi = new Eseye(); - try { - $character = $esi->invoke('get', '/characters/{character_id}/', [ - 'character_id' => $charId, - ]); - - $corporation = $esi->invoke('get', '/corporations/{corporation_id}/', [ - 'corporation_id' => $character->corporation_id, - ]); - } catch(RequestFailedException $e) { - return null; - } - - return $corporation->name; - } - public function DecodeDate($date) { //Find the end of the date $dateEnd = strpos($date, "T"); diff --git a/app/Models/Jobs/JobSendEveMail.php b/app/Models/Jobs/JobSendEveMail.php new file mode 100644 index 0000000..182eebe --- /dev/null +++ b/app/Models/Jobs/JobSendEveMail.php @@ -0,0 +1,21 @@ +=7.0", + "symfony/debug": "^3|^4", + "symfony/finder": "^3|^4" + }, + "require-dev": { + "laravel/framework": "5.5.x" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.2-dev" + }, + "laravel": { + "providers": [ + "Barryvdh\\Debugbar\\ServiceProvider" + ], + "aliases": { + "Debugbar": "Barryvdh\\Debugbar\\Facade" + } + } + }, + "autoload": { + "psr-4": { + "Barryvdh\\Debugbar\\": "src/" + }, + "files": [ + "src/helpers.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Barry vd. Heuvel", + "email": "barryvdh@gmail.com" + } + ], + "description": "PHP Debugbar integration for Laravel", + "keywords": [ + "debug", + "debugbar", + "laravel", + "profiler", + "webprofiler" + ], + "time": "2019-08-29T07:01:03+00:00" + }, { "name": "dnoegel/php-xdg-base-dir", "version": "0.1", @@ -1193,6 +1261,67 @@ ], "time": "2016-08-17T00:36:58+00:00" }, + { + "name": "maximebf/debugbar", + "version": "v1.15.0", + "source": { + "type": "git", + "url": "https://github.com/maximebf/php-debugbar.git", + "reference": "30e7d60937ee5f1320975ca9bc7bcdd44d500f07" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/maximebf/php-debugbar/zipball/30e7d60937ee5f1320975ca9bc7bcdd44d500f07", + "reference": "30e7d60937ee5f1320975ca9bc7bcdd44d500f07", + "shasum": "" + }, + "require": { + "php": ">=5.3.0", + "psr/log": "^1.0", + "symfony/var-dumper": "^2.6|^3.0|^4.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0|^5.0" + }, + "suggest": { + "kriswallsmith/assetic": "The best way to manage assets", + "monolog/monolog": "Log using Monolog", + "predis/predis": "Redis storage" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.14-dev" + } + }, + "autoload": { + "psr-4": { + "DebugBar\\": "src/DebugBar/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Maxime Bouroumeau-Fuseau", + "email": "maxime.bouroumeau@gmail.com", + "homepage": "http://maximebf.com" + }, + { + "name": "Barry vd. Heuvel", + "email": "barryvdh@gmail.com" + } + ], + "description": "Debug bar in the browser for php application", + "homepage": "https://github.com/maximebf/php-debugbar", + "keywords": [ + "debug", + "debugbar" + ], + "time": "2017-12-15T11:13:46+00:00" + }, { "name": "monolog/monolog", "version": "1.25.1", diff --git a/config/queue.php b/config/queue.php index 3a30d6c..bc273cd 100644 --- a/config/queue.php +++ b/config/queue.php @@ -13,7 +13,7 @@ return [ | */ - 'default' => env('QUEUE_CONNECTION', 'sync'), + 'default' => env('QUEUE_CONNECTION', 'redis'), /* |-------------------------------------------------------------------------- diff --git a/config/session.php b/config/session.php index fbb9b4d..c68016b 100644 --- a/config/session.php +++ b/config/session.php @@ -18,7 +18,7 @@ return [ | */ - 'driver' => env('SESSION_DRIVER', 'file'), + 'driver' => env('SESSION_DRIVER', 'redis'), /* |-------------------------------------------------------------------------- diff --git a/database/migrations/2019_09_29_034922_create_jobs_table.php b/database/migrations/2019_09_29_034922_create_jobs_table.php new file mode 100644 index 0000000..fce118f --- /dev/null +++ b/database/migrations/2019_09_29_034922_create_jobs_table.php @@ -0,0 +1,38 @@ +bigIncrements('id'); + $table->string('queue')->index(); + $table->longText('payload'); + $table->unsignedTinyInteger('attempts'); + $table->unsignedInteger('reserved_at')->nullable(); + $table->unsignedInteger('available_at'); + $table->unsignedInteger('created_at'); + }); + } + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('jobs'); + } +}