diff --git a/.env.example b/.env.example index ac748637ae52e837bedc4234dbcad2f82e5187e7..833a1e13f73312d5671f6b52cba2d7fe07afb81f 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,4 @@ -APP_NAME=Laravel +APP_NAME=contribulle APP_ENV=local APP_KEY= APP_DEBUG=true @@ -29,7 +29,7 @@ MAIL_PORT=2525 MAIL_USERNAME=null MAIL_PASSWORD=null MAIL_ENCRYPTION=null -MAIL_FROM_ADDRESS=null +MAIL_FROM_ADDRESS=no-reply@contribulle.org MAIL_FROM_NAME="${APP_NAME}" AWS_ACCESS_KEY_ID= diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 431bb573e07d80afd7373c8f48fc976c06e318c3..ea6e55a9c878e9963a1d5acacc6aaa05e528c149 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -5,6 +5,7 @@ namespace App\Http\Controllers; use App\Models\Tag; use App\Models\Project; use App\Models\Category; +use App\Notifications\CreateSuccessfully; use App\Http\Requests\StoreProjectRequest; use Illuminate\Support\Facades\Http; @@ -88,6 +89,8 @@ class ProjectController extends Controller { abort_if(!session()->has('authorization'), 403); + $project->notify(new CreateSuccessfully()); + return view('projects.success', [ 'link' => $project->path_admin, 'project_id' => $project->id diff --git a/app/Models/Project.php b/app/Models/Project.php index 3b1ccb639e1b8b6e43a3da153079a426808abda3..eff4b39c4946964c00474aef8454e3166b85393e 100644 --- a/app/Models/Project.php +++ b/app/Models/Project.php @@ -4,11 +4,13 @@ namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; +use Illuminate\Notifications\Notifiable; use Illuminate\Support\Str; class Project extends Model { use HasFactory; + use Notifiable; protected $guarded = ['id']; @@ -38,4 +40,16 @@ class Project extends Model { return $this->belongsToMany(Tag::class); } + + /** + * Route notifications for the mail channel. + * + * @param \Illuminate\Notifications\Notification $notification + * @return array|string + */ + public function routeNotificationForMail($notification) + { + // Return email address and name... + return [$this->email => $this->creator]; + } } diff --git a/app/Notifications/CreateSuccessfully.php b/app/Notifications/CreateSuccessfully.php new file mode 100644 index 0000000000000000000000000000000000000000..1b31bb48c6f44c04325c9bc7b6342590f7570ca4 --- /dev/null +++ b/app/Notifications/CreateSuccessfully.php @@ -0,0 +1,68 @@ +subject('[' . config('app.name') . '] Publication de votre annonce') + ->greeting('Votre annonce a été publiée sur Contribulle') + ->line('Merci d’avoir créé une annonce sur Contribulle.') + ->line('Vous pouvez la modifier ou la supprimer à l’aide de ce lien: ') + ->action("Modifier ou supprimer mon annonce", $notifiable->path_admin) + ->line('Si vous n\'arrivez pas à cliquer sur le bouton, copiez-collez ce lien dans votre navigateur 😉 : '. $notifiable->path_admin) + ->line('N’hésitez pas à diffuser votre annonce autant que vous le souhaitez !') + ->line('Pour faire un retour sur les contributions effectuées, envoyez-nous un mail. Vos témoignages, en tant que porteur·ses de projet et que contributeur·rices, nous sont importants pour pouvoir améliorer Contribulle selon vos besoins.') + ->line('Bullement vôtre 🙂') + ->salutation('Le collectif Contribulle'); + } + + /** + * Get the array representation of the notification. + * + * @param mixed $notifiable + * @return array + */ + public function toArray($notifiable) + { + return [ + // + ]; + } +} diff --git a/resources/views/vendor/mail/html/button.blade.php b/resources/views/vendor/mail/html/button.blade.php new file mode 100644 index 0000000000000000000000000000000000000000..7b2b8ba593b06b136b5c4d555ad31e81bf12ee7b --- /dev/null +++ b/resources/views/vendor/mail/html/button.blade.php @@ -0,0 +1,20 @@ + + + + + \ No newline at end of file diff --git a/resources/views/vendor/mail/html/footer.blade.php b/resources/views/vendor/mail/html/footer.blade.php new file mode 100644 index 0000000000000000000000000000000000000000..5de782eff611726980197d0a75e80a156a4465b0 --- /dev/null +++ b/resources/views/vendor/mail/html/footer.blade.php @@ -0,0 +1,12 @@ + + + + + + + + + \ No newline at end of file diff --git a/resources/views/vendor/mail/html/header.blade.php b/resources/views/vendor/mail/html/header.blade.php new file mode 100644 index 0000000000000000000000000000000000000000..a04d5c82e328aee658ad720943a081d6c0c1a48d --- /dev/null +++ b/resources/views/vendor/mail/html/header.blade.php @@ -0,0 +1,7 @@ + + + + {{ $slot }} + + + \ No newline at end of file diff --git a/resources/views/vendor/mail/html/layout.blade.php b/resources/views/vendor/mail/html/layout.blade.php new file mode 100644 index 0000000000000000000000000000000000000000..bbffb0c68a14d978bfd158d6e2a7c613cbfaae02 --- /dev/null +++ b/resources/views/vendor/mail/html/layout.blade.php @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/resources/views/vendor/mail/html/message.blade.php b/resources/views/vendor/mail/html/message.blade.php new file mode 100644 index 0000000000000000000000000000000000000000..13c5f20941f70be49631e0ea3c08e99c75853c08 --- /dev/null +++ b/resources/views/vendor/mail/html/message.blade.php @@ -0,0 +1,26 @@ +@component('mail::layout') +{{-- Header --}} +@slot('header') +@component('mail::header', ['url' => config('app.url')]) +@endcomponent +@endslot + +{{-- Body --}} +{{ $slot }} + +{{-- Subcopy --}} +@isset($subcopy) +@slot('subcopy') +@component('mail::subcopy') +{{ $subcopy }} +@endcomponent +@endslot +@endisset + +{{-- Footer --}} +@slot('footer') +@component('mail::footer') +© {{ date('Y') }} {{ config('app.name') }}. @lang('All rights reserved.') +@endcomponent +@endslot +@endcomponent \ No newline at end of file diff --git a/resources/views/vendor/mail/html/panel.blade.php b/resources/views/vendor/mail/html/panel.blade.php new file mode 100644 index 0000000000000000000000000000000000000000..c1ec767172bdafe9446a71aa467fd8ce90374995 --- /dev/null +++ b/resources/views/vendor/mail/html/panel.blade.php @@ -0,0 +1,13 @@ + + + + + \ No newline at end of file diff --git a/resources/views/vendor/mail/html/subcopy.blade.php b/resources/views/vendor/mail/html/subcopy.blade.php new file mode 100644 index 0000000000000000000000000000000000000000..248bd97802f948a477a2274b73f2c1555bb20b55 --- /dev/null +++ b/resources/views/vendor/mail/html/subcopy.blade.php @@ -0,0 +1,7 @@ + + + + + \ 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 0000000000000000000000000000000000000000..7eb2d08dd76d6248beac7a6064fbb7201a2ec4a1 --- /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/resources/views/vendor/mail/html/themes/default.css b/resources/views/vendor/mail/html/themes/default.css new file mode 100644 index 0000000000000000000000000000000000000000..71a7f88f7f63deda201a5039659c58cc1b1157e9 --- /dev/null +++ b/resources/views/vendor/mail/html/themes/default.css @@ -0,0 +1,267 @@ +/* Base */ + +body, +body *:not(html):not(style):not(br):not(tr):not(code) { + box-sizing: border-box; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, + "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"; + position: relative; +} + +body { + -webkit-text-size-adjust: none; + background-color: #ffffff; + color: #0a003f; + height: 100%; + line-height: 1.4; + margin: 0; + padding: 0; + width: 100% !important; +} + +p, +ul, +ol, +blockquote { + line-height: 1.4; + text-align: left; +} + +a { + color: #3869d4; +} + +a img { + border: none; +} + +/* Typography */ + +h1 { + font-size: 18px; + font-weight: bold; + margin-top: 0; + text-align: left; +} + +h2 { + font-size: 16px; + font-weight: bold; + margin-top: 0; + text-align: left; +} + +h3 { + font-size: 14px; + font-weight: bold; + margin-top: 0; + text-align: left; +} + +p { + font-size: 16px; + line-height: 1.5em; + margin-top: 0; + text-align: left; +} + +p.sub { + font-size: 12px; +} + +img { + max-width: 100%; +} + +/* Layout */ + +.wrapper { + -premailer-cellpadding: 0; + -premailer-cellspacing: 0; + -premailer-width: 100%; + background-color: #ffffff; + margin: 0; + padding: 0; + width: 100%; +} + +.content { + -premailer-cellpadding: 0; + -premailer-cellspacing: 0; + -premailer-width: 100%; + margin: 0; + padding: 0; + width: 100%; +} + +/* Header */ + +.header { + padding: 25px 0; + text-align: center; +} + +.header a { + font-size: 19px; + font-weight: bold; + text-decoration: none; +} + +/* Logo */ + +.logo { + height: 75px; + width: 75px; +} + +/* Body */ + +.body { + -premailer-cellpadding: 0; + -premailer-cellspacing: 0; + -premailer-width: 100%; + background-color: #ffffff; + margin: 0; + padding: 0; + width: 100%; +} + +.inner-body { + -premailer-cellpadding: 0; + -premailer-cellspacing: 0; + -premailer-width: 570px; + background-color: #ffffff; + border-radius: 2px; + border-width: 1px; + margin: 0 auto; + padding: 0; + width: 570px; +} + +/* Subcopy */ + +.subcopy { + margin-top: 25px; + padding-top: 25px; +} + +.subcopy p { + font-size: 14px; +} + +/* Footer */ + +.footer { + -premailer-cellpadding: 0; + -premailer-cellspacing: 0; + -premailer-width: 570px; + margin: 0 auto; + padding: 0; + text-align: center; + width: 570px; +} + +.footer p { + font-size: 12px; + text-align: center; +} + +/* Tables */ + +.table table { + -premailer-cellpadding: 0; + -premailer-cellspacing: 0; + -premailer-width: 100%; + margin: 30px auto; + width: 100%; +} + +.table th { + margin: 0; + padding-bottom: 8px; +} + +.table td { + font-size: 15px; + line-height: 18px; + margin: 0; + padding: 10px 0; +} + +.content-cell { + max-width: 100vw; + padding: 32px; +} + +/* Buttons */ + +.action { + -premailer-cellpadding: 0; + -premailer-cellspacing: 0; + -premailer-width: 100%; + margin: 30px auto; + padding: 0; + text-align: center; + width: 100%; +} + +.button { + -webkit-text-size-adjust: none; + border-radius: 4px; + color: #fff; + display: inline-block; + overflow: hidden; + text-decoration: none; +} + +.button-blue, +.button-primary { + background-color: #2d3748; + border-bottom: 8px solid #2d3748; + border-left: 18px solid #2d3748; + border-right: 18px solid #2d3748; + border-top: 8px solid #2d3748; +} + +.button-green, +.button-success { + background-color: #48bb78; + border-bottom: 8px solid #48bb78; + border-left: 18px solid #48bb78; + border-right: 18px solid #48bb78; + border-top: 8px solid #48bb78; +} + +.button-red, +.button-error { + background-color: #e53e3e; + border-bottom: 8px solid #e53e3e; + border-left: 18px solid #e53e3e; + border-right: 18px solid #e53e3e; + border-top: 8px solid #e53e3e; +} + +/* Panels */ + +.panel { + margin: 21px 0; +} + +.panel-content { + padding: 16px; +} + +.panel-item { + padding: 0; +} + +.panel-item p:last-of-type { + margin-bottom: 0; + padding-bottom: 0; +} + +/* Utilities */ + +.break-all { + word-break: break-all; +} diff --git a/resources/views/vendor/mail/text/button.blade.php b/resources/views/vendor/mail/text/button.blade.php new file mode 100644 index 0000000000000000000000000000000000000000..791a94bbd643105e484e1e722151d488712cc328 --- /dev/null +++ b/resources/views/vendor/mail/text/button.blade.php @@ -0,0 +1 @@ +{{ $slot }}: {{ $url }} \ No newline at end of file diff --git a/resources/views/vendor/mail/text/footer.blade.php b/resources/views/vendor/mail/text/footer.blade.php new file mode 100644 index 0000000000000000000000000000000000000000..3338f620e42f9e0b2bb4829eb7795681bd7b2523 --- /dev/null +++ b/resources/views/vendor/mail/text/footer.blade.php @@ -0,0 +1 @@ +{{ $slot }} diff --git a/resources/views/vendor/mail/text/header.blade.php b/resources/views/vendor/mail/text/header.blade.php new file mode 100644 index 0000000000000000000000000000000000000000..aaa3e5754446d837da5bcf4977505f00f25171e9 --- /dev/null +++ b/resources/views/vendor/mail/text/header.blade.php @@ -0,0 +1 @@ +[{{ $slot }}]({{ $url }}) diff --git a/resources/views/vendor/mail/text/layout.blade.php b/resources/views/vendor/mail/text/layout.blade.php new file mode 100644 index 0000000000000000000000000000000000000000..9378baa0771b7818e4a6c884359ba8c3aa12ab97 --- /dev/null +++ b/resources/views/vendor/mail/text/layout.blade.php @@ -0,0 +1,9 @@ +{!! strip_tags($header) !!} + +{!! strip_tags($slot) !!} +@isset($subcopy) + +{!! strip_tags($subcopy) !!} +@endisset + +{!! strip_tags($footer) !!} diff --git a/resources/views/vendor/mail/text/message.blade.php b/resources/views/vendor/mail/text/message.blade.php new file mode 100644 index 0000000000000000000000000000000000000000..1ae9ed8f1bf6385b7deb293b80af4485811e0ce3 --- /dev/null +++ b/resources/views/vendor/mail/text/message.blade.php @@ -0,0 +1,27 @@ +@component('mail::layout') + {{-- Header --}} + @slot('header') + @component('mail::header', ['url' => config('app.url')]) + {{ config('app.name') }} + @endcomponent + @endslot + + {{-- Body --}} + {{ $slot }} + + {{-- Subcopy --}} + @isset($subcopy) + @slot('subcopy') + @component('mail::subcopy') + {{ $subcopy }} + @endcomponent + @endslot + @endisset + + {{-- Footer --}} + @slot('footer') + @component('mail::footer') + © {{ date('Y') }} {{ config('app.name') }}. @lang('All rights reserved.') + @endcomponent + @endslot +@endcomponent diff --git a/resources/views/vendor/mail/text/panel.blade.php b/resources/views/vendor/mail/text/panel.blade.php new file mode 100644 index 0000000000000000000000000000000000000000..3338f620e42f9e0b2bb4829eb7795681bd7b2523 --- /dev/null +++ b/resources/views/vendor/mail/text/panel.blade.php @@ -0,0 +1 @@ +{{ $slot }} diff --git a/resources/views/vendor/mail/text/subcopy.blade.php b/resources/views/vendor/mail/text/subcopy.blade.php new file mode 100644 index 0000000000000000000000000000000000000000..3338f620e42f9e0b2bb4829eb7795681bd7b2523 --- /dev/null +++ b/resources/views/vendor/mail/text/subcopy.blade.php @@ -0,0 +1 @@ +{{ $slot }} diff --git a/resources/views/vendor/mail/text/table.blade.php b/resources/views/vendor/mail/text/table.blade.php new file mode 100644 index 0000000000000000000000000000000000000000..3338f620e42f9e0b2bb4829eb7795681bd7b2523 --- /dev/null +++ b/resources/views/vendor/mail/text/table.blade.php @@ -0,0 +1 @@ +{{ $slot }} diff --git a/resources/views/vendor/notifications/email.blade.php b/resources/views/vendor/notifications/email.blade.php new file mode 100644 index 0000000000000000000000000000000000000000..e7a56b461d94ca2112883849935b1f836f9b588f --- /dev/null +++ b/resources/views/vendor/notifications/email.blade.php @@ -0,0 +1,62 @@ +@component('mail::message') +{{-- Greeting --}} +@if (! empty($greeting)) +# {{ $greeting }} +@else +@if ($level === 'error') +# @lang('Whoops!') +@else +# @lang('Hello!') +@endif +@endif + +{{-- Intro Lines --}} +@foreach ($introLines as $line) +{{ $line }} + +@endforeach + +{{-- Action Button --}} +@isset($actionText) + +@component('mail::button', ['url' => $actionUrl, 'color' => $color]) +{{ $actionText }} +@endcomponent +@endisset + +{{-- Outro Lines --}} +@foreach ($outroLines as $line) +{{ $line }} + +@endforeach + +{{-- Salutation --}} +@if (! empty($salutation)) +{{ $salutation }} +@else +@lang('Regards'),
+{{ config('app.name') }} +@endif + +{{-- Subcopy --}} +@isset($actionText) +@slot('subcopy') +@lang( + "If you’re having trouble clicking the \":actionText\" button, copy and paste the URL below\n". + 'into your web browser:', + [ + 'actionText' => $actionText, + ] +) [{{ $displayableActionUrl }}]({{ $actionUrl }}) +@endslot +@endisset +@endcomponent