Tag.php 344 B

12345678910111213141516171819202122
  1. <?php
  2. namespace App;
  3. use Illuminate\Database\Eloquent\Model;
  4. class Tag extends Model
  5. {
  6. const LABEL_KEY = 'name';
  7. protected $fillable = [self::LABEL_KEY];
  8. public function getRouteKeyName()
  9. {
  10. return static::LABEL_KEY;
  11. }
  12. public function posts()
  13. {
  14. return $this->belongsToMany(Post::class);
  15. }
  16. }