Tag.php 573 B

123456789101112131415161718192021222324252627
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Factories\HasFactory;
  4. use Illuminate\Database\Eloquent\Model;
  5. class Tag extends Model
  6. {
  7. use HasFactory;
  8. protected $fillable = [
  9. 'name',
  10. 'slug',
  11. ];
  12. protected $casts = [
  13. 'created_at' => 'datetime',
  14. 'updated_at' => 'datetime',
  15. ];
  16. // Связь многие-ко-многим: тег может быть у многих заявок
  17. public function submissions()
  18. {
  19. return $this->belongsToMany(Submission::class, 'submission_tag');
  20. }
  21. }