From: Louis Jeckel Date: Tue, 20 Oct 2020 18:08:30 +0000 (+0200) Subject: email tempaltes X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=f14930a5e8fc33ba5fc70c6e59faa4987039c6ab;p=psq.git email tempaltes --- diff --git a/.idea/lettre-pharma.iml b/.idea/lettre-pharma.iml index 958a20c..ec91958 100644 --- a/.idea/lettre-pharma.iml +++ b/.idea/lettre-pharma.iml @@ -38,6 +38,7 @@ + diff --git a/.idea/php.xml b/.idea/php.xml index 89cd65d..c3e55ff 100644 --- a/.idea/php.xml +++ b/.idea/php.xml @@ -210,6 +210,7 @@ + diff --git a/app/EmailTemplate.php b/app/EmailTemplate.php new file mode 100644 index 0000000..55615be --- /dev/null +++ b/app/EmailTemplate.php @@ -0,0 +1,64 @@ +templateAttribute($match); + + }, $content); + + } + + /** + * @param User $user + * @return string + */ + public function fillFor(User $user) + { + return self::fillWithContentFor($user, $this->content); + } + + + /** + * @param $url + * @param $label + * @param null $color + * @return string + * @throws \Throwable + */ + public static function button($url, $label, $color = null) + { + return view('vendor.mail.html.button', [ + 'url' => $url, + 'slot' => $label, + 'color' => $color + ])->render(); + } +} diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index 5c9ec41..c25e7ac 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -90,6 +90,11 @@ class RegisterController extends Controller */ protected function create(array $data) { + + $type = request()->boolean('trial') ? + User::TYPE_DISCOVER : + User::TYPE_PLATFORM_ONLY; + /** @var User $user */ $user = User::query()->updateOrCreate( [ @@ -101,16 +106,11 @@ class RegisterController extends Controller 'employer' => $data['employer'], 'password' => Hash::make($data['password']), 'reg_complete' => true, - 'type' => User::TYPE_DISCOVER, + 'type' => $type, 'self_registered' => true, ] ); - if(! request()->boolean('no_trial')){ - $user->startTrial(); - } - -// $user->sendEmailVerificationNotification(); return $user; } diff --git a/app/Http/Controllers/DebugController.php b/app/Http/Controllers/DebugController.php new file mode 100644 index 0000000..5300018 --- /dev/null +++ b/app/Http/Controllers/DebugController.php @@ -0,0 +1,16 @@ +fillFor(User::first())); + } +} diff --git a/app/Mail/TemplateMail.php b/app/Mail/TemplateMail.php new file mode 100644 index 0000000..27167b1 --- /dev/null +++ b/app/Mail/TemplateMail.php @@ -0,0 +1,40 @@ +content = $content; + } + + /** + * Build the message. + * + * @return $this + */ + public function build() + { + return $this->markdown('emails.template'); + } +} diff --git a/app/Nova/EmailTemplate.php b/app/Nova/EmailTemplate.php new file mode 100644 index 0000000..c0db024 --- /dev/null +++ b/app/Nova/EmailTemplate.php @@ -0,0 +1,107 @@ +hideFromIndex(), + Text::make('Nom', 'name'), + Text::make('Sujet', 'subject'), + CKEditor5Classic::make('Contenu', 'content')->alwaysShow(), + ]; + } + + /** + * Get the cards available for the request. + * + * @param \Illuminate\Http\Request $request + * @return array + */ + public function cards(Request $request) + { + return []; + } + + /** + * Get the filters available for the resource. + * + * @param \Illuminate\Http\Request $request + * @return array + */ + public function filters(Request $request) + { + return []; + } + + /** + * Get the lenses available for the resource. + * + * @param \Illuminate\Http\Request $request + * @return array + */ + public function lenses(Request $request) + { + return []; + } + + /** + * Get the actions available for the resource. + * + * @param \Illuminate\Http\Request $request + * @return array + */ + public function actions(Request $request) + { + return []; + } +} diff --git a/app/TemplateVariables.php b/app/TemplateVariables.php new file mode 100644 index 0000000..a7c5d2d --- /dev/null +++ b/app/TemplateVariables.php @@ -0,0 +1,70 @@ +templateVariables)) { + return $this->{$snake}; + } + + return $this->hasTemplateGetter($key) ? + $this->{'get'.Str::studly($key).'Template'}() : + $default; + } + + + /** + * @return string + * @throws \Throwable + */ + public function getLoginButtonTemplate() + { + return EmailTemplate::button(route('login'), 'Login'); + } + + /** + * @return string + * @throws \Throwable + */ + public function getMyAccountTemplate() + { + return EmailTemplate::button( + $this->routeWithToken('account.index'), + 'Accéder à mon compte' + ); + } + +} diff --git a/app/User.php b/app/User.php index 111e363..246d820 100644 --- a/app/User.php +++ b/app/User.php @@ -4,7 +4,6 @@ namespace App; use App\Notifications\EmailValidated; -use DemeterChain\B; use Illuminate\Contracts\Auth\MustVerifyEmail; use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Relations\BelongsTo; @@ -45,6 +44,7 @@ class User extends Authenticatable implements MustVerifyEmail use Notifiable; use Searchable; use Billable; + use TemplateVariables; /** * The attributes that are mass assignable. @@ -160,6 +160,7 @@ class User extends Authenticatable implements MustVerifyEmail public const TYPE_PROSPECT = 1; public const TYPE_SPECIAL = 2; public const TYPE_DISCOVER = 3; + public const TYPE_PLATFORM_ONLY = 4; /** * @return array diff --git a/composer.json b/composer.json index 4a34a45..3e4e85c 100644 --- a/composer.json +++ b/composer.json @@ -36,6 +36,7 @@ "league/html-to-markdown": "^4.9", "mailgun/mailgun-php": "^3.0", "masterminds/html5": "^2.7", + "numaxlab/nova-ckeditor5-classic": "^1.1", "nyholm/psr7": "^1.2", "psq/psq-theme": "*", "pusher/pusher-php-server": "~4.0", diff --git a/composer.lock b/composer.lock index 99992a6..c3ddfae 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": "d48521f562f0e300ac0313ea4875d488", + "content-hash": "ca6ddddface6393f6a339cd2a7233c9b", "packages": [ { "name": "algolia/algoliasearch-client-php", @@ -4729,6 +4729,49 @@ ], "time": "2020-08-18T19:48:01+00:00" }, + { + "name": "numaxlab/nova-ckeditor5-classic", + "version": "1.1.1", + "source": { + "type": "git", + "url": "https://github.com/numaxlab/nova-ckeditor5-classic.git", + "reference": "1a2f045b5df699ada4bae055a0a5c331c74d3c61" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/numaxlab/nova-ckeditor5-classic/zipball/1a2f045b5df699ada4bae055a0a5c331c74d3c61", + "reference": "1a2f045b5df699ada4bae055a0a5c331c74d3c61", + "shasum": "" + }, + "require": { + "php": ">=7.1.0" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "NumaxLab\\NovaCKEditor5Classic\\FieldServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "NumaxLab\\NovaCKEditor5Classic\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A Laravel Nova CKEditor5 Classic Field.", + "keywords": [ + "ckeditor5", + "laravel", + "nova", + "wysiwyg" + ], + "time": "2020-02-17T15:42:14+00:00" + }, { "name": "nyholm/psr7", "version": "1.3.0", diff --git a/config/ckeditor5Classic.php b/config/ckeditor5Classic.php new file mode 100644 index 0000000..5b8f73a --- /dev/null +++ b/config/ckeditor5Classic.php @@ -0,0 +1,107 @@ + [ + 'language' => 'fr', + 'toolbar' => [ + 'Heading', + 'Bold', + 'Italic', + 'fontColor', + 'fontSize', + '-', + 'Link', + '-', + 'NumberedList', + 'BulletedList', + 'BlockQuote', + '-', + 'MediaEmbed', + 'imageUpload', + ], + 'image' => [ + 'toolbar' => [ + 'imageTextAlternative', '|', + 'imageStyle:alignLeft', + 'imageStyle:full', + 'imageStyle:alignRight' + ], + 'styles' => [ + // This option is equal to a situation where no style is applied. + 'full', + // This represents an image aligned to the left. + 'alignLeft', + // This represents an image aligned to the right. + 'alignRight', + ] + ], + 'fontColor' => [ + 'colors' => [ + [ + 'label' => 'psq_red', + 'color' => '#d04d4a', + ], + [ + 'label' => 'psq_blue', + 'color' => '#074e9c', + ], + [ + 'label' => 'psq_light_blue', + 'color' => '#cddceb', + ], + [ + 'label' => 'psq_purple', + 'color' => '#AD5ED3', + ], + [ + 'label' => 'psq_cyan', + 'color' => '#288ed7', + ], + [ + 'label' => 'psq_magenta', + 'color' => '#ce317c', + ], + [ + 'label' => 'psq_orange', + 'color' => '#e79817', + ], + [ + 'label' => 'psq_grey', + 'color' => '#546983', + ], + [ + 'label' => 'psq_denim', + 'color' => '#0c2c50', + ], + [ + 'label' => 'psq_green', + 'color' => '#41BD53', + ], + [ + 'label' => 'psq_mag_blue', + 'color' => '#2a6ba3', + ], + + ] + + ], + 'heading' => [ + 'options' => [ + [ 'model' => 'paragraph', 'title' => 'Paragraph', 'class' => 'ck-heading_paragraph' ], + [ 'model' => 'heading1', 'view' => 'h2', 'title' => 'Titre 1', 'class' => 'ck-heading_heading1' ], + [ 'model' => 'heading2', 'view' => 'h3', 'title' => 'Titre 2', 'class' => 'ck-heading_heading2' ] + ] + ], + ] + +]; diff --git a/database/migrations/2020_10_20_132301_create_email_templates_table.php b/database/migrations/2020_10_20_132301_create_email_templates_table.php new file mode 100644 index 0000000..8f385ca --- /dev/null +++ b/database/migrations/2020_10_20_132301_create_email_templates_table.php @@ -0,0 +1,34 @@ +id(); + $table->string('slug'); + $table->string('name'); + $table->text('subject')->nullable(); + $table->text('content'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('email_templates'); + } +} diff --git a/resources/views/auth/register.blade.php b/resources/views/auth/register.blade.php index a1961d0..ad6f4cf 100644 --- a/resources/views/auth/register.blade.php +++ b/resources/views/auth/register.blade.php @@ -107,10 +107,10 @@
- + -
diff --git a/resources/views/emails/template.blade.php b/resources/views/emails/template.blade.php new file mode 100644 index 0000000..11f1524 --- /dev/null +++ b/resources/views/emails/template.blade.php @@ -0,0 +1,4 @@ +@component('mail::message') +{!! $content !!} +@endcomponent + diff --git a/resources/views/home/index.blade.php b/resources/views/home/index.blade.php index 3dd58a6..f64b4a2 100644 --- a/resources/views/home/index.blade.php +++ b/resources/views/home/index.blade.php @@ -29,7 +29,7 @@
@endif -

L'actualité à la une de notre quotidien

+

L'actualité du médicament à la une de notre quotidien

    diff --git a/routes/web.php b/routes/web.php index 66e046d..809f432 100644 --- a/routes/web.php +++ b/routes/web.php @@ -133,3 +133,7 @@ Route::domain('{client_domains}')->group(function() { }); }); + +if(config('app.env') === 'local') { + Route::get('debug', 'DebugController@test'); +}