From cd18b9885999f0b325565d9f1a983e41ef6afe4b Mon Sep 17 00:00:00 2001 From: Deon George Date: Sun, 9 Feb 2020 23:12:34 +1100 Subject: [PATCH] Fixed order email, added site url tests, add doctrine/dbal, add service::site() --- .gitlab-ci.yml | 1 - app/Models/Payment.php | 4 +- app/Models/Product.php | 3 +- app/Models/Service.php | 11 + composer.json | 1 + composer.lock | 252 +++++++++++++++++- .../layouts/partials/mainheader.blade.php | 4 +- .../views/email/admin/order/approve.blade.php | 38 ++- .../views/vendor/mail/html/table.blade.php | 3 + tests/Feature/SiteURLTest.php | 27 ++ 10 files changed, 316 insertions(+), 28 deletions(-) create mode 100644 resources/views/vendor/mail/html/table.blade.php create mode 100644 tests/Feature/SiteURLTest.php diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 59e17a8..6346dd5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -38,7 +38,6 @@ before_script: - mkdir -p /root/.composer - if [ -n "$GITHUB_TOKEN" ]; then cat $GITHUB_TOKEN |base64 -d > /root/.composer/auth.json ; fi - composer install - - composer require doctrine/dbal # Copy over testing configuration. # Don't forget to set the database config in .env.testing correctly diff --git a/app/Models/Payment.php b/app/Models/Payment.php index 6739ac2..d3e5ec5 100644 --- a/app/Models/Payment.php +++ b/app/Models/Payment.php @@ -9,12 +9,12 @@ use App\Traits\NextKey; class Payment extends Model { use NextKey; + const RECORD_ID = 'payment'; + public $incrementing = FALSE; const CREATED_AT = 'date_orig'; const UPDATED_AT = 'date_last'; - const RECORD_ID = 'payment'; - public $incrementing = FALSE; protected $table = 'ab_payment'; protected $dates = ['date_payment']; protected $dateFormat = 'U'; diff --git a/app/Models/Product.php b/app/Models/Product.php index e7d9721..821bf83 100644 --- a/app/Models/Product.php +++ b/app/Models/Product.php @@ -11,15 +11,14 @@ use App\Traits\NextKey; class Product extends Model { use NextKey; - const RECORD_ID = 'product'; + public $incrementing = FALSE; protected $table = 'ab_product'; protected $with = ['descriptions']; const CREATED_AT = 'date_orig'; const UPDATED_AT = 'date_last'; - public $incrementing = FALSE; public $dateFormat = 'U'; public function descriptions() diff --git a/app/Models/Service.php b/app/Models/Service.php index 9640f54..0428974 100644 --- a/app/Models/Service.php +++ b/app/Models/Service.php @@ -184,6 +184,17 @@ class Service extends Model return $this->belongsTo(Product::class); } + /** + * The site this service is configured for + * + * @todo It may be more appropriate to get this from the account->user attribute (ie: for mail actions) + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + */ + public function site() + { + return $this->belongsTo(Site::class); + } + /** * Return a child model with details of the service * diff --git a/composer.json b/composer.json index 92605d2..cebf9f8 100644 --- a/composer.json +++ b/composer.json @@ -12,6 +12,7 @@ "barryvdh/laravel-snappy": "^0.4.6", "beyondcode/laravel-websockets": "^1.3", "clarkeash/doorman": "^4.0", + "doctrine/dbal": "^2.10", "eduardokum/laravel-mail-auto-embed": "^1.0", "fideloper/proxy": "^4.0", "h4cc/wkhtmltoimage-amd64": "^0.12.4", diff --git a/composer.lock b/composer.lock index 7bd0e2e..ae70e37 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "9f5c683a75f22be193805e80ff064350", + "content-hash": "c66583693e58610054b0cb827890548b", "packages": [ { "name": "barryvdh/laravel-snappy", @@ -428,6 +428,256 @@ ], "time": "2018-07-24T23:27:56+00:00" }, + { + "name": "doctrine/cache", + "version": "1.10.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/cache.git", + "reference": "382e7f4db9a12dc6c19431743a2b096041bcdd62" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/cache/zipball/382e7f4db9a12dc6c19431743a2b096041bcdd62", + "reference": "382e7f4db9a12dc6c19431743a2b096041bcdd62", + "shasum": "" + }, + "require": { + "php": "~7.1" + }, + "conflict": { + "doctrine/common": ">2.2,<2.4" + }, + "require-dev": { + "alcaeus/mongo-php-adapter": "^1.1", + "doctrine/coding-standard": "^6.0", + "mongodb/mongodb": "^1.1", + "phpunit/phpunit": "^7.0", + "predis/predis": "~1.0" + }, + "suggest": { + "alcaeus/mongo-php-adapter": "Required to use legacy MongoDB driver" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.9.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Common\\Cache\\": "lib/Doctrine/Common/Cache" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "PHP Doctrine Cache library is a popular cache implementation that supports many different drivers such as redis, memcache, apc, mongodb and others.", + "homepage": "https://www.doctrine-project.org/projects/cache.html", + "keywords": [ + "abstraction", + "apcu", + "cache", + "caching", + "couchdb", + "memcached", + "php", + "redis", + "xcache" + ], + "time": "2019-11-29T15:36:20+00:00" + }, + { + "name": "doctrine/dbal", + "version": "v2.10.1", + "source": { + "type": "git", + "url": "https://github.com/doctrine/dbal.git", + "reference": "c2b8e6e82732a64ecde1cddf9e1e06cb8556e3d8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/dbal/zipball/c2b8e6e82732a64ecde1cddf9e1e06cb8556e3d8", + "reference": "c2b8e6e82732a64ecde1cddf9e1e06cb8556e3d8", + "shasum": "" + }, + "require": { + "doctrine/cache": "^1.0", + "doctrine/event-manager": "^1.0", + "ext-pdo": "*", + "php": "^7.2" + }, + "require-dev": { + "doctrine/coding-standard": "^6.0", + "jetbrains/phpstorm-stubs": "^2019.1", + "phpstan/phpstan": "^0.11.3", + "phpunit/phpunit": "^8.4.1", + "symfony/console": "^2.0.5|^3.0|^4.0|^5.0" + }, + "suggest": { + "symfony/console": "For helpful console commands such as SQL execution and import of files." + }, + "bin": [ + "bin/doctrine-dbal" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.10.x-dev", + "dev-develop": "3.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\DBAL\\": "lib/Doctrine/DBAL" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + } + ], + "description": "Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.", + "homepage": "https://www.doctrine-project.org/projects/dbal.html", + "keywords": [ + "abstraction", + "database", + "db2", + "dbal", + "mariadb", + "mssql", + "mysql", + "oci8", + "oracle", + "pdo", + "pgsql", + "postgresql", + "queryobject", + "sasql", + "sql", + "sqlanywhere", + "sqlite", + "sqlserver", + "sqlsrv" + ], + "time": "2020-01-04T12:56:21+00:00" + }, + { + "name": "doctrine/event-manager", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/event-manager.git", + "reference": "629572819973f13486371cb611386eb17851e85c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/event-manager/zipball/629572819973f13486371cb611386eb17851e85c", + "reference": "629572819973f13486371cb611386eb17851e85c", + "shasum": "" + }, + "require": { + "php": "^7.1" + }, + "conflict": { + "doctrine/common": "<2.9@dev" + }, + "require-dev": { + "doctrine/coding-standard": "^6.0", + "phpunit/phpunit": "^7.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Common\\": "lib/Doctrine/Common" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + }, + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com" + } + ], + "description": "The Doctrine Event Manager is a simple PHP event system that was built to be used with the various Doctrine projects.", + "homepage": "https://www.doctrine-project.org/projects/event-manager.html", + "keywords": [ + "event", + "event dispatcher", + "event manager", + "event system", + "events" + ], + "time": "2019-11-10T09:48:07+00:00" + }, { "name": "doctrine/inflector", "version": "1.3.1", diff --git a/resources/theme/frontend/metronic/layouts/partials/mainheader.blade.php b/resources/theme/frontend/metronic/layouts/partials/mainheader.blade.php index a38d310..3a1ed87 100644 --- a/resources/theme/frontend/metronic/layouts/partials/mainheader.blade.php +++ b/resources/theme/frontend/metronic/layouts/partials/mainheader.blade.php @@ -15,7 +15,9 @@
diff --git a/resources/views/email/admin/order/approve.blade.php b/resources/views/email/admin/order/approve.blade.php index 430a806..7c9d454 100644 --- a/resources/views/email/admin/order/approve.blade.php +++ b/resources/views/email/admin/order/approve.blade.php @@ -1,30 +1,26 @@ -@component('mail::message',['site'=>$site,'heading'=>'Please Order the following...']) -# Please order the following service. - -@component('mail::panel') +@component('mail::message',['site'=>$site,'heading'=>'New Order']) +Please order the following... @component('mail::table') - | Service | Details | - | :---------- | :---------------- | - | Account | {{ $service->account_name }} ({!! $service->account->account_id_url !!}) | - | Service ID | {!! $service->service_id_url !!} | - | Product | {{ $service->product_name }} | - @switch($service->product_category) - @case('ADSL') - | Address | {{ $service->type->service_address }} | - @break; - @case('VOIP') - | Number | {{ $service->type->service_number }} | - | Supplier Details | {{ join(':',$service->order_info) }} | - @break; - @endswitch - +| Service | Details | +| :---------- | :---------------- | +| Account | {{ $service->account_name }} ({!! $service->account->account_id_url !!}) | +| Service ID | {!! $service->service_id_url !!} | +| Product | {{ $service->product_name }} | +@switch($service->product_category) +@case('ADSL') +| Address | {{ $service->type->service_address }} | +@break; +@case('VOIP') +| Number | {{ $service->type->service_number }} | +| Supplier Details | {{ join(':',$service->order_info) }} | +@break; +@endswitch @endcomponent + **NOTES:** {{ $notes }} -@endcomponent - Thanks,
{{ config('app.name') }} @endcomponent \ No newline at end of file diff --git a/resources/views/vendor/mail/html/table.blade.php b/resources/views/vendor/mail/html/table.blade.php new file mode 100644 index 0000000..3c98d3c --- /dev/null +++ b/resources/views/vendor/mail/html/table.blade.php @@ -0,0 +1,3 @@ +
+{{ Illuminate\Mail\Markdown::parse($slot) }} +
\ No newline at end of file diff --git a/tests/Feature/SiteURLTest.php b/tests/Feature/SiteURLTest.php new file mode 100644 index 0000000..fb7d86c --- /dev/null +++ b/tests/Feature/SiteURLTest.php @@ -0,0 +1,27 @@ +get('/'); + + $response->assertStatus(200); + } + + public function testLoginURL() + { + $response = $this->get('/login'); + + $response->assertStatus(200); + } +} \ No newline at end of file