]> BookStack Code Mirror - bookstack/commitdiff
Adding getHeadingExcerpt to get heading.
authorNilesh Deepak <redacted>
Sat, 15 Jul 2017 10:41:10 +0000 (16:11 +0530)
committerNilesh Deepak <redacted>
Sat, 15 Jul 2017 10:41:10 +0000 (16:11 +0530)
app/Book.php

index afec7a35148913ec5b472e3b276c65267bb587ed..be90e0e1af707d97c4775fab4a09a7e32c167e60 100644 (file)
@@ -32,6 +32,12 @@ class Book extends Entity
         return $cover;
     }
 
+    public function getHeadingExcerpt($length = 35)
+    {
+        $heading = $this->name;
+        return strlen($heading) > $length ? substr($heading, 0, $length-3) . '...' : $heading;
+    }
+    
     public function cover()
     {
         return $this->belongsTo(Image::class, 'image');