namespace App\Http\Controllers;
use App\LoginToken;
+use App\Notifications\WantsPdfNotification;
use App\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
}
+ /**
+ * @param Request $request
+ * @param User $user
+ * @return \Illuminate\Http\RedirectResponse
+ */
+ public function askPdf(Request $request, User $user)
+ {
+ if (! $request->hasValidSignature()) {
+ abort(401);
+ }
+ $user->update(['wants_pdf' => true]);
+
+ Session::flash('message', 'Votre demande à bien été prise en compte, merci !');
+ return redirect()->route('home');
+
+ }
+
+ /**
+ * @param Request $request
+ * @param User $user
+ * @return string
+ */
public function unsubscribe(Request $request, User $user)
{
if (! $request->hasValidSignature()) {
return "Désinscription bien prise en compte";
-
}
}
--- /dev/null
+<?php
+
+namespace App\Notifications;
+
+use App\User;
+use Illuminate\Bus\Queueable;
+use Illuminate\Contracts\Queue\ShouldQueue;
+use Illuminate\Notifications\Messages\MailMessage;
+use Illuminate\Notifications\Notification;
+
+class WantsPdfNotification extends Notification
+{
+ use Queueable;
+
+ /**
+ * @var User
+ */
+ private User $user;
+
+ /**
+ * Create a new notification instance.
+ *
+ * @return void
+ */
+ public function __construct(User $user)
+ {
+ $this->user = $user;
+ }
+
+ /**
+ * Get the notification's delivery channels.
+ *
+ * @param mixed $notifiable
+ * @return array
+ */
+ public function via($notifiable)
+ {
+ return ['mail'];
+ }
+
+ /**
+ * Get the mail representation of the notification.
+ *
+ * @param mixed $notifiable
+ * @return \Illuminate\Notifications\Messages\MailMessage
+ */
+ public function toMail($notifiable)
+ {
+ return (new MailMessage)
+ ->subject("{$this->user} a demandé à reçevoir la version PDF.")
+ ->greeting('Bonjour,')
+ ->line("{$this->user} a demandé à reçevoir la version PDF de la lettre à l'adresse **{$this->user->email}**");
+ }
+
+ /**
+ * Get the array representation of the notification.
+ *
+ * @param mixed $notifiable
+ * @return array
+ */
+ public function toArray($notifiable)
+ {
+ return [
+ //
+ ];
+ }
+}
public function handle(ActionFields $fields, Collection $models)
{
- $models->map(fn($sendsEmail) => $sendsEmail->sendEmailFromTemplate($fields->notification));
+ $models->map(fn($sendsEmail) => $sendsEmail->sendEmailFromTemplate(EmailTemplate::findOrFail($fields->notification)));
return Action::message(sprintf('%d messages envoyés', $models->count()));
}
public function fields()
{
$options = EmailTemplate::query()
- ->pluck('name', 'slug')
+ ->pluck('name', 'id')
->toArray();
return [
namespace App\Observers;
+use App\Notifications\WantsPdfNotification;
use App\User;
class UserObserver
\Session::flash('registration_complete');
}
+
+ if(
+ $user->wants_pdf === true &&
+ $user->isDirty('wants_pdf') &&
+ $user->getOriginal()['wants_pdf'] === false
+ ) {
+ \Notification::route('mail', config('app.emails.subscriptions'))
+ ->notify(new WantsPdfNotification($user));
+ }
+
+
+
}
}
+ /**
+ * @return string
+ * @throws \Throwable
+ */
+ public function getAskPdfButtonTemplate()
+ {
+ $route = \URL::signedRoute('account.ask-pdf', ['user' => $this->id]);
+ return EmailTemplate::button(
+ $route,
+ 'Reçevoir le PDF'
+ );
+ }
+
+
+ /**
+ * @return string
+ */
+ public function getOrganizationTemplate()
+ {
+ return (string) $this->organization;
+ }
}
}
+ /**
+ * @return string
+ */
+ public function __toString()
+ {
+ return $this->name;
+ }
}
<x-pill-box class="my-5" title="Nous suivre">
<section class="social-box mx-3">
<p><i class="fab fa-twitter-square mr-2"></i><a target="_blank" href="https://twitter.com/PSLeQuotidien">@PSLeQuotidien</a></p>
- <p><i class="fab fa-linkedin mr-2"></i><a target="_blank" href="https://fr.linkedin.com/in/prescription-sant%C3%A9-le-quotidien-747b14159">LinkedIn</a></p>
+ <p><i class="fab fa-linkedin mr-2"></i><a target="_blank" href="https://www.linkedin.com/company/prescription-sant%C3%A9/">LinkedIn</a></p>
</section>
</x-pill-box>
LE 20 SEPTEMBRE PROCHAIN : MISE EN LIGNE DU SOMMAIRE COMPLET DE CE PREMIER NUMÉRO
</p>
<p style="font-size: larger;" class="font-weight-bold mb-0">
- N°1 : LE 25 OCTOBRE 2020
+ N°1 : JANVIER / FÉVRIER 2021
</p>
<p>
<a href="mailto:publicite@prescription-quotidien.com">
Route::post('password', 'AccountController@password')->name('account.password');
});
+ Route::get('compte/{user}/demander-pdf', 'AccountController@askPdf')->name('account.ask-pdf');
/** Stripe Payment */
Route::prefix('pay')->middleware('auth')->group(function() {