| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- <?php
- namespace App;
- use Illuminate\Database\Eloquent\Model;
- use Illuminate\Notifications\Notifiable;
- class News extends Model
- {
- use Notifiable;
- protected $fillable = [
- 'section_id',
- 'region_1_id',
- 'region_2_id',
- 'page_id',
- 'event_id',
- 'title',
- 'title_region_1',
- 'title_region_2',
- 'text_short',
- 'text',
- 'image',
- 'online',
- 'homepage',
- 'date',
- 'slug',
- 'meta_title',
- 'meta_description',
- 'meta_keywords',
- 'live',
- 'image1',
- 'image2',
- 'image3',
- 'image4',
- 'image5',
- 'video',
- 'pdf',
- 'breaking_news',
- 'clicks',
- 'section_position',
- 'region_1_position',
- 'region_2_position',
- 'published'
- ];
- public function section()
- {
- return $this->belongsTo('App\Section');
- }
- public function region_1()
- {
- return $this->belongsTo('App\Section');
- }
- public function region_2()
- {
- return $this->belongsTo('App\Section');
- }
- public function event()
- {
- return $this->belongsTo('App\Event');
- }
- public function page()
- {
- return $this->belongsTo('App\Page');
- }
- public function user()
- {
- return $this->belongsTo('App\Models\User');
- }
- public function getCurrentTitle($section_id)
- {
- $title = '';
- if ($this->section_id == $section_id)
- $title = $this->title;
- if ($this->region_1_id == $section_id)
- $title = $this->title_region_1;
- if ($this->region_2_id == $section_id)
- $title = $this->title_region_2;
- if ($title == '')
- $title = $this->title;
- return $title;
- }
- }
|