News.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. namespace App;
  3. use Illuminate\Database\Eloquent\Model;
  4. use Illuminate\Notifications\Notifiable;
  5. class News extends Model
  6. {
  7. use Notifiable;
  8. protected $fillable = [
  9. 'section_id',
  10. 'region_1_id',
  11. 'region_2_id',
  12. 'page_id',
  13. 'event_id',
  14. 'title',
  15. 'title_region_1',
  16. 'title_region_2',
  17. 'text_short',
  18. 'text',
  19. 'image',
  20. 'online',
  21. 'homepage',
  22. 'date',
  23. 'slug',
  24. 'meta_title',
  25. 'meta_description',
  26. 'meta_keywords',
  27. 'live',
  28. 'image1',
  29. 'image2',
  30. 'image3',
  31. 'image4',
  32. 'image5',
  33. 'video',
  34. 'pdf',
  35. 'breaking_news',
  36. 'clicks',
  37. 'section_position',
  38. 'region_1_position',
  39. 'region_2_position',
  40. 'published'
  41. ];
  42. public function section()
  43. {
  44. return $this->belongsTo('App\Section');
  45. }
  46. public function region_1()
  47. {
  48. return $this->belongsTo('App\Section');
  49. }
  50. public function region_2()
  51. {
  52. return $this->belongsTo('App\Section');
  53. }
  54. public function event()
  55. {
  56. return $this->belongsTo('App\Event');
  57. }
  58. public function page()
  59. {
  60. return $this->belongsTo('App\Page');
  61. }
  62. public function user()
  63. {
  64. return $this->belongsTo('App\User');
  65. }
  66. public function getCurrentTitle($section_id)
  67. {
  68. $title = '';
  69. if ($this->section_id == $section_id)
  70. $title = $this->title;
  71. if ($this->region_1_id == $section_id)
  72. $title = $this->title_region_1;
  73. if ($this->region_2_id == $section_id)
  74. $title = $this->title_region_2;
  75. if ($title == '')
  76. $title = $this->title;
  77. return $title;
  78. }
  79. }