]> _ Git - psq.git/commitdiff
meta on social article and adcampaign
authorLouis Jeckel <louis.jeckel@outlook.cm>
Mon, 14 Sep 2020 14:12:16 +0000 (16:12 +0200)
committerLouis Jeckel <louis.jeckel@outlook.cm>
Mon, 14 Sep 2020 14:12:16 +0000 (16:12 +0200)
app/Http/Controllers/ActuLabosController.php
app/Http/Controllers/AdCampaignController.php
app/Models/AdCampaign.php
app/Models/HasMetaTags.php
app/Models/LaboArticle.php

index c5160e6c120b6795c26733de1f848dd570e86df0..3dc38b72913380b2641285c73f9ada4c36295488 100644 (file)
@@ -19,10 +19,12 @@ class ActuLabosController extends Controller
 
     public function show($slug, LaboArticleRepository $repository)
     {
+        /** @var LaboArticle $actu */
         $actu = $repository->forSlug($slug);
 
         \View::share('title', $actu->title);
         \View::share('actu', $actu);
+        \View::share('meta', $actu->getMetaData());
 
         return view('actu-labos.show');
     }
index bf9ef831d18a2870cf3367251c11a60e0f31fd06..854c0a13c4c90c260e1beee9496e923ac12eb783 100644 (file)
@@ -35,9 +35,11 @@ class AdCampaignController extends Controller
 
     public function show($slug, AdCampaignRepository $repository)
     {
+        /** @var AdCampaign $campaign */
         $campaign = $repository->forSlug($slug);
         \View::share('campaign', $campaign);
         \View::share('title', $campaign->title);
+        \View::share('meta', $campaign->getMetaData());
 
         return view('com-campaigns.show');
 
index 49054d12b4fe5ffd9202925657a9a6269073d119..34e8e3ee901d1d0e98bbee60706bbded1b5f2bff 100644 (file)
@@ -14,11 +14,15 @@ use Laravel\Scout\Searchable;
  * Class AdCampaign
  * @package App\Models
  * @property string $url
+ * @property string $title
+ * @property string $description
+ * @property string $content
+ *
  */
 class AdCampaign extends Model implements Sortable, PillBoxContract
 {
     use HasSlug, HasMedias, HasPosition, HasSubscriberOnlyContent;
-    use Searchable;
+    use Searchable, HasMetaTags;
 
     protected $fillable = [
         'published',
@@ -52,6 +56,12 @@ class AdCampaign extends Model implements Sortable, PillBoxContract
                     'ratio' => 0,
                 ],
             ],
+            'social' => [
+                [
+                    'name' => 'Social',
+                    'ratio' => 1,
+                ],
+            ],
 
         ],
     ];
@@ -88,4 +98,18 @@ class AdCampaign extends Model implements Sortable, PillBoxContract
     {
         return route('com-campaign.show', ['slug' => $this->slug]) ?? '#';
     }
+
+    /**
+     * @return string
+     */
+    protected function getMetaDescription(): string
+    {
+        return $this->description;
+    }
+
+    protected function getMetaImage(): string
+    {
+        return $this->image('image', 'social', [], true) ??
+            $this->image('image', 'preview');
+    }
 }
index c8912ad9826b6e15b5a572bab616217fac598866..0572f59f019be4a4d9a303a06e1a273ff1d0de9d 100644 (file)
@@ -10,7 +10,7 @@ trait HasMetaTags
     {
         return [
             'title' => $this->getMetaTitle(),
-            'description' => $this->getMetaDescription(),
+            'description' => strip_tags($this->getMetaDescription()),
             'image' => $this->getMetaImage(),
             'url' => $this->getMetaUrl(),
         ];
@@ -24,7 +24,7 @@ trait HasMetaTags
 
     protected function getMetaDescription(): string
     {
-        return strip_tags($this->chapo);
+        return $this->chapo;
     }
 
     protected function getMetaImage(): string
index fcb674acdfa3f9f3bb973af4e0496527b11380c3..10d01764eaaeae2bddfa3d51035876aa56c2f49a 100644 (file)
@@ -18,7 +18,7 @@ use Laravel\Scout\Searchable;
  */
 class LaboArticle extends Model implements Sortable, PillBoxContract
 {
-    use HasSlug, HasMedias, HasPosition, HasSubscriberOnlyContent;
+    use HasSlug, HasMedias, HasPosition, HasSubscriberOnlyContent, HasMetaTags;
 
     protected $fillable = [
         'publish_start_date',
@@ -46,6 +46,12 @@ class LaboArticle extends Model implements Sortable, PillBoxContract
                     'ratio' => 0,
                 ],
             ],
+            'social' => [
+                [
+                    'name' => 'social',
+                    'ratio' => 1,
+                ]
+            ]
         ],
     ];
 
@@ -69,5 +75,23 @@ class LaboArticle extends Model implements Sortable, PillBoxContract
         return route('actus-labos.show', ['slug' => $this->slug]);
     }
 
+    /**
+     * @return string
+     */
+    protected function getMetaDescription(): string
+    {
+        return $this->preview;
+    }
+
+
+    /**
+     * @return string
+     */
+    protected function getMetaImage(): string
+    {
+        return $this->image('image', 'social', [], true) ??
+            $this->image('image');
+    }
+
 
 }