]> _ Git - psq.git/commitdiff
wip #7904 @2
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 18 Dec 2025 14:40:01 +0000 (15:40 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Thu, 18 Dec 2025 14:40:01 +0000 (15:40 +0100)
app/Helpers/Asset.php
app/Http/Controllers/Admin/PublishController.php
app/Jobs/ProcessEmailBatch.php
app/PdfFile.php
config/app.php
resources/views/emails/batch-pdf.blade.php [deleted file]

index da302e417a19c0cdb066c48de1b6338ecdbd98b5..5ac0894a4969e4b9eb50fe51199ef635eb25eb3c 100644 (file)
@@ -15,7 +15,7 @@ class Asset
      */
     public static function public($file)
     {
-        return config('app.aws_s3_url')."/public/$file";
+        return str_replace('https://admin.','https://',url(str_replace('//', '/', '/s3/' . $file)));
     }
 
     /**
@@ -24,6 +24,6 @@ class Asset
      */
     public static function assetVersion($path)
     {
-        return asset($path).'?v='.filemtime(public_path($path));
+        return asset($path) . '?v=' . filemtime(public_path($path));
     }
 }
index 008e74fbb591f1ab7696093a1fe1347717287e51..5bab39cdd0286424a06d5106b14b5bcb4e914d61 100644 (file)
@@ -11,6 +11,7 @@ use App\Jobs\ProcessPdfFile;
 use App\Mail\BatchMail;
 use App\PdfFile;
 use App\User;
+use Cubist\Util\ArrayUtil;
 use Illuminate\Database\Eloquent\Builder;
 use Illuminate\Http\Request;
 use Illuminate\Http\Resources\Json\ResourceCollection;
@@ -42,6 +43,21 @@ class PublishController extends Controller
     public function publish(Request $request)
     {
         $data = $request->input('data');
+        $default = ['email' =>
+            [
+                'subject' => "L'édition du jour [" . $data['file']['title'] . "]",
+                'content' => '<p>Bonjour %name%,</p>
+                        <p>Voici la nouvelle édition du jour !</p>
+                        <br>
+                        <div style="text-align: center;width: 300px;margin:0 auto;">
+                        <a href="%url%"><img src="%cover%" style="width:300px;height:auto;" /></a><br>
+                        <a href="%url%" style="margin: 0 auto;border-radius: 5px;color: #fff;background-color: #074e9c;">Cliquez ici pour lire !</a>
+                        </div>'
+            ],
+        ];
+
+        $data = ArrayUtil::mergeOverwriteNull($default, $data);
+
 
         $recipientGroup = Arr::get($data, 'recipient_group');
 
index 169509a872d28c0410100f9da30600db314b1046..284dba7473a0d6207017213ca4d0cc3027069a37 100644 (file)
@@ -144,14 +144,21 @@ class ProcessEmailBatch implements ShouldQueue
         ]);
         $i = 0;
 
+
         $this->html = $this->batch->render();
         $this->templateVariables = $this->processVariablesForMailer();
 
         foreach ($this->users as $user) {
             Mail::send([], [], function ($message) use ($user) {
+                $h = $this->html;
+                $h = str_replace('%name%', $user->name, $h);
+                $h = str_replace('%url%', $this->batch->file->getMailableUrl($user), $h);
+                $h = str_replace('%cover%', $this->batch->file->coverUrl, $h);
+                dd($h);
+
                 $message->from(config('mail.from.address'), config('mail.from_name'));
                 $message->subject($this->batch->subject);
-                $message->setBody($this->html, 'text/html');
+                $message->setBody($h, 'text/html');
                 $message->to($user->email);
                 $message->replyTo(env('MAIL_REPLYTO'));
             });
index f24340264aaf44e7575be211a5fc779e03c7cbba..4967a510a4786380be02dd3844f391a6b3f9dc02 100644 (file)
@@ -369,7 +369,7 @@ class PdfFile extends TwillModel implements Sortable
      */
     public function getCoverUrlAttribute(): string
     {
-        return url(str_replace('fluidbook', 'view', $this->coverPath));
+        return str_replace('https://admin.', 'https://', url(str_replace('fluidbook', 'view', $this->coverPath)));
     }
 
     /**
index 1f50653e89efeedf319e8bc739a1b9b4719dcb33..7412901ddc7575fabeca62c1376c1140507acd4c 100644 (file)
@@ -130,7 +130,7 @@ return [
     'emails' => [
         'subscriptions' => 'abonnement@prescription-quotidien.com',
         'olivier' => 'olivier.robichon@prescription-quotidien.com',
-        'moi' => 'soufiane@cubedesigners.com'
+        'moi' => 'test+psq@fluidbook.com'
     ],
 
 
diff --git a/resources/views/emails/batch-pdf.blade.php b/resources/views/emails/batch-pdf.blade.php
deleted file mode 100644 (file)
index c75360c..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-@component('mail::message')
-
-# {{$subject}}
-
-
-<table width="100%" border="0" cellspacing="0" cellpadding="0">
-    <tr>
-        <td align="center">
-            <a href="{{$link ?? '%recipient.file_url%'}}" target="_blank">
-                <img src="{!! $image !!}" alt="cover"  width="300" style="width:300px;" >
-            </a>
-        </td>
-    </tr>
-</table>
-<br>
-
-{!! $content !!}
-
-@component('mail::button', ['url' =>  $link ?? '%recipient.file_url%', 'color' => 'primary'])
-Cliquez ici pour lire !
-@endcomponent
-
-
-@endcomponent
-