]> BookStack Code Mirror - bookstack/blobdiff - app/Entities/Models/Entity.php
Improve sorting Shelf Books
[bookstack] / app / Entities / Models / Entity.php
index f764ad16efb8cf8f94a44f38aaccbccb33cdd642..c6b2468b0814afd124d1c64a4e0f8b116b9ec8d5 100644 (file)
@@ -9,7 +9,9 @@ use BookStack\Auth\Permissions\JointPermission;
 use BookStack\Entities\Tools\SearchIndex;
 use BookStack\Entities\Tools\SlugGenerator;
 use BookStack\Facades\Permissions;
-use BookStack\Ownable;
+use BookStack\Model;
+use BookStack\Traits\HasCreatorAndUpdater;
+use BookStack\Traits\HasOwner;
 use Carbon\Carbon;
 use Illuminate\Database\Eloquent\Builder;
 use Illuminate\Database\Eloquent\Collection;
@@ -35,9 +37,11 @@ use Illuminate\Database\Eloquent\SoftDeletes;
  * @method static Builder withLastView()
  * @method static Builder withViewCount()
  */
-abstract class Entity extends Ownable
+abstract class Entity extends Model
 {
     use SoftDeletes;
+    use HasCreatorAndUpdater;
+    use HasOwner;
 
     /**
      * @var string - Name of property where the main text content is found
@@ -205,12 +209,12 @@ abstract class Entity extends Ownable
     }
 
     /**
-     * Get entity type.
-     * @return mixed
+     * Get the entity type as a simple lowercase word.
      */
-    public static function getType()
+    public static function getType(): string
     {
-        return strtolower(static::getClassName());
+        $className = array_slice(explode('\\', static::class), -1, 1)[0];
+        return strtolower($className);
     }
 
     /**