1<?php
2
3// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0.
4// See the LICENCE file in the repository root for full licence text.
5
6namespace App\Models\Traits;
7
8use App\Models\Comment;
9
10trait CommentableDefaults
11{
12 public function comments()
13 {
14 return $this->morphMany(Comment::class, 'commentable');
15 }
16
17 public function getCommentableIdentifierAttribute()
18 {
19 return "{$this->getMorphClass()}:{$this->getKey()}";
20 }
21
22 // title for display in comments listing
23 abstract public function commentableTitle();
24}