| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- <?php
- namespace App;
- use Illuminate\Database\Eloquent\Model;
- class Event extends Model
- {
- protected $fillable = [
- 'title',
- 'text_short',
- 'text',
- 'image',
- 'slug',
- 'online',
- 'big',
- 'small1',
- 'small2',
- 'small3',
- 'small4'
- ];
- function loadLayout()
- {
- $this->data = $this;
- if ($this->big != '')
- {
- $n = News::find($this->big);
- if ($n != null)
- {
- if (!$n->online)
- $n = null;
- $this->big = $n;
- }
- }
-
- if ($this->small1 != '')
- {
- $n = News::find($this->small1);
- if($n != null)
- {
- if (!$n->online)
- $n = null;
- $this->small1 = $n;
- }
- }
- if ($this->small2 != '')
- {
- $n = News::find($this->small2);
- if($n != null)
- {
- if (!$n->online)
- $n = null;
- $this->small2 = $n;
- }
- }
- if ($this->small3 != '')
- {
- $n = News::find($this->small3);
- if($n != null)
- {
- if (!$n->online)
- $n = null;
- $this->small3 = $n;
- }
- }
- if ($this->small4 != '')
- {
- $n = News::find($this->small4);
- if($n != null)
- {
- if (!$n->online)
- $n = null;
- $this->small4 = $n;
- }
- }
- if ($this->small5 != '')
- {
- $n = News::find($this->small5);
- if($n != null)
- {
- if (!$n->online)
- $n = null;
- $this->small5 = $n;
- }
- }
- if ($this->small6 != '')
- {
- $n = News::find($this->small6);
- if($n != null)
- {
- if (!$n->online)
- $n = null;
- $this->small6 = $n;
- }
- }
- }
- public function advs()
- {
- return $this->hasMany('App\EventAdv');
- }
-
- public function getAdvs()
- {
-
- $advs['Sopra 234x60 1'] = array();
- $advs['Sopra 234x60 2'] = array();
- $advs['Sopra 234x60 3'] = array();
- $advs['Sopra 234x60 4'] = array();
- $advs['Sotto 234x60 1'] = array();
- $advs['Sotto 234x60 2'] = array();
- $advs['Sotto 234x60 3'] = array();
- $advs['Sotto 234x60 4'] = array();
- $advs['728x90'] = array();
- $event_advs = $this->advs()->where('online', '=', true)->get();
- foreach($event_advs as $a)
- {
- $advs[$a->position][] = $a;
- }
- return $advs;
- }
- }
|