Author.php 313 B

12345678910111213141516171819
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. use Illuminate\Database\Eloquent\SoftDeletes;
  5. class Author extends Model
  6. {
  7. use SoftDeletes;
  8. function books() {
  9. return $this->hasMany(Book::class);
  10. }
  11. function comments() {
  12. return $this->morphMany(Comment::class, "commentable");
  13. }
  14. }