]> _ Git - psq.git/commitdiff
labo article on top
authorLouis Jeckel <louis.jeckel@outlook.cm>
Sat, 3 Oct 2020 16:03:24 +0000 (18:03 +0200)
committerLouis Jeckel <louis.jeckel@outlook.cm>
Sat, 3 Oct 2020 16:03:24 +0000 (18:03 +0200)
app/Models/HasPositionTop.php [new file with mode: 0644]
app/Models/LaboArticle.php

diff --git a/app/Models/HasPositionTop.php b/app/Models/HasPositionTop.php
new file mode 100644 (file)
index 0000000..862fa19
--- /dev/null
@@ -0,0 +1,22 @@
+<?php
+
+namespace App\Models;
+
+
+use A17\Twill\Models\Behaviors\HasPosition;
+
+trait HasPositionTop
+{
+    use HasPosition;
+
+    protected function setToLastPosition()
+    {
+        $this->position = $this->getCurrentLastPosition() - 1;
+    }
+
+    protected function getCurrentLastPosition()
+    {
+        return ((int) static::min('position'));
+    }
+
+}
index 2b9784fec7ff085bbe2d79868ff9cf196a471783..a2059a3c5ef09ccd2a7c0994e6c3d6b0367a4bfd 100644 (file)
@@ -18,7 +18,7 @@ use Laravel\Scout\Searchable;
  */
 class LaboArticle extends Model implements Sortable, PillBoxContract
 {
-    use HasSlug, HasMedias, HasPosition, HasSubscriberOnlyContent, HasMetaTags;
+    use HasSlug, HasMedias, HasPositionTop, HasSubscriberOnlyContent, HasMetaTags;
 
     protected $fillable = [
         'publish_start_date',
@@ -95,4 +95,5 @@ class LaboArticle extends Model implements Sortable, PillBoxContract
     }
 
 
+
 }