<excludeFolder url="file://$MODULE_DIR$/vendor/masterminds/html5" />
<excludeFolder url="file://$MODULE_DIR$/vendor/maximebf/debugbar" />
<excludeFolder url="file://$MODULE_DIR$/vendor/moneyphp/money" />
+ <excludeFolder url="file://$MODULE_DIR$/vendor/numaxlab/nova-ckeditor5-classic" />
<excludeFolder url="file://$MODULE_DIR$/vendor/nyholm/psr7" />
<excludeFolder url="file://$MODULE_DIR$/vendor/paragonie/random_compat" />
<excludeFolder url="file://$MODULE_DIR$/vendor/paragonie/sodium_compat" />
<path value="$PROJECT_DIR$/vendor/judev/php-htmltruncator" />
<path value="$PROJECT_DIR$/vendor/html2text/html2text" />
<path value="$PROJECT_DIR$/vendor/psq/psq-theme" />
+ <path value="$PROJECT_DIR$/vendor/numaxlab/nova-ckeditor5-classic" />
</include_path>
</component>
<component name="PhpInterpreters">
--- /dev/null
+<?php
+
+namespace App;
+
+use Illuminate\Database\Eloquent\Model;
+use Illuminate\Support\Str;
+
+/**
+ * Class EmailTemplate
+ * @package App
+ * @property string $subject
+ * @property string $content
+ * @property string $slug
+ */
+class EmailTemplate extends Model
+{
+ public $timestamps = false;
+
+
+ /**
+ * @param $user
+ * @param $content
+ * @return string
+ */
+ public static function fillWithContentFor($user, $content)
+ {
+ $content = preg_replace('/<a /', '<a target="_blank"', $content);
+
+ return preg_replace_callback('/%[^(% )]*%/', function($matches) use($user){
+
+ $match = Str::before(Str::after($matches[0], '%'), '%');
+
+ return $user->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();
+ }
+}
*/
protected function create(array $data)
{
+
+ $type = request()->boolean('trial') ?
+ User::TYPE_DISCOVER :
+ User::TYPE_PLATFORM_ONLY;
+
/** @var User $user */
$user = User::query()->updateOrCreate(
[
'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;
}
--- /dev/null
+<?php
+
+namespace App\Http\Controllers;
+
+use App\EmailTemplate;
+use App\Mail\TemplateMail;
+use App\User;
+use Illuminate\Http\Request;
+
+class DebugController extends Controller
+{
+ public function test()
+ {
+ return new TemplateMail(EmailTemplate::first()->fillFor(User::first()));
+ }
+}
--- /dev/null
+<?php
+
+namespace App\Mail;
+
+use App\EmailTemplate;
+use Illuminate\Bus\Queueable;
+use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Mail\Mailable;
+use Illuminate\Queue\SerializesModels;
+
+class TemplateMail extends Mailable
+{
+ use Queueable, SerializesModels;
+
+ /**
+ * @var string
+ */
+ public $content;
+
+
+ /**
+ * Create a new message instance.
+ *
+ * @param $content
+ */
+ public function __construct($content)
+ {
+ $this->content = $content;
+ }
+
+ /**
+ * Build the message.
+ *
+ * @return $this
+ */
+ public function build()
+ {
+ return $this->markdown('emails.template');
+ }
+}
--- /dev/null
+<?php
+
+namespace App\Nova;
+
+use Illuminate\Http\Request;
+use Laravel\Nova\Fields\ID;
+use Laravel\Nova\Fields\Text;
+use Laravel\Nova\Fields\Trix;
+use Laravel\Nova\Http\Requests\NovaRequest;
+use NumaxLab\NovaCKEditor5Classic\CKEditor5Classic;
+
+class EmailTemplate extends Resource
+{
+ /**
+ * The model the resource corresponds to.
+ *
+ * @var string
+ */
+ public static $model = \App\EmailTemplate::class;
+
+ public static $group = "Emails";
+
+
+ /**
+ * The single value that should be used to represent the resource when being displayed.
+ *
+ * @var string
+ */
+ public static $title = 'name';
+
+
+ /**
+ * @return string
+ */
+ public static function label()
+ {
+ return "Modèles d'email";
+ }
+
+ /**
+ * @return string
+ */
+ public static function singularLabel()
+ {
+ return "Modèle d'email";
+ }
+
+ /**
+ * Get the fields displayed by the resource.
+ *
+ * @param \Illuminate\Http\Request $request
+ * @return array
+ */
+ public function fields(Request $request)
+ {
+ return [
+ Text::make('Nom code', 'slug')->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 [];
+ }
+}
--- /dev/null
+<?php
+
+
+namespace App;
+
+
+use Illuminate\Support\Str;
+
+trait TemplateVariables
+{
+ protected $templateVariables = [
+ 'first_name',
+ 'last_name',
+ 'name',
+ ];
+
+
+ /**
+ * Determine if a getter exists for a template attribute.
+ *
+ * @param string $key
+ * @return bool
+ */
+ public function hasTemplateGetter(string $key)
+ {
+ return method_exists($this, 'get'.Str::studly($key).'Template');
+ }
+
+
+ /**
+ * Get the value of a template attribute using its getter.
+ *
+ * @param string $key
+ * @return mixed
+ */
+ public function templateAttribute(string $key, $default = null)
+ {
+ $snake = Str::snake($key);
+ if(in_array($snake, $this->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'
+ );
+ }
+
+}
use App\Notifications\EmailValidated;
-use DemeterChain\B;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Notifiable;
use Searchable;
use Billable;
+ use TemplateVariables;
/**
* The attributes that are mass assignable.
public const TYPE_PROSPECT = 1;
public const TYPE_SPECIAL = 2;
public const TYPE_DISCOVER = 3;
+ public const TYPE_PLATFORM_ONLY = 4;
/**
* @return array
"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",
"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",
],
"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",
--- /dev/null
+<?php
+return [
+
+ /*
+ |--------------------------------------------------------------------------------
+ | CKEditor Options
+ |--------------------------------------------------------------------------------
+ |
+ | To view a list of all available options checkout the CKEditor API documentation
+ | https://ckeditor.com/docs/ckeditor5/latest/builds/guides/integration/configuration.html
+ |
+ */
+
+ 'options' => [
+ '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' ]
+ ]
+ ],
+ ]
+
+];
--- /dev/null
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+class CreateEmailTemplatesTable extends Migration
+{
+ /**
+ * Run the migrations.
+ *
+ * @return void
+ */
+ public function up()
+ {
+ Schema::create('email_templates', function (Blueprint $table) {
+ $table->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');
+ }
+}
<div class="form-group row">
<div class="col-md-6 offset-md-4">
<div class="form-check">
- <input class="form-check-input" type="checkbox" id="no_trial" name="no_trial" {{old('no_trial', false) ? 'checked' : ''}}>
+ <input class="form-check-input" type="checkbox" id="trial" name="trial" {{old('trial', false) ? 'checked' : ''}}>
- <label class="form-check-label" for="no_trial">
- Je ne souhaite PAS reçevoir les prochains numéros gratuitement pednant 2 semaines.
+ <label class="form-check-label" for="trial">
+ Je souhaite demander l'activation d'une période d'essai pour reçevoir gratuitement les prochains numéros de PSQ.
</label>
</div>
--- /dev/null
+@component('mail::message')
+{!! $content !!}
+@endcomponent
+
</div>
@endif
- <h1>L'actualité à la une de notre quotidien</h1>
+ <h1>L'actualité du médicament à la une de notre quotidien</h1>
<div class="row justify-content-center pt-3">
<div class="col-md-4">
<ul class="leaders">
});
});
+
+if(config('app.env') === 'local') {
+ Route::get('debug', 'DebugController@test');
+}