Book.php 316 B

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