Page.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace App;
  3. use Illuminate\Database\Eloquent\Model;
  4. class Page extends Model
  5. {
  6. protected $fillable = [
  7. 'title',
  8. 'text_short',
  9. 'text',
  10. 'slug',
  11. 'image',
  12. 'online',
  13. 'web',
  14. 'email',
  15. 'facebook',
  16. 'twitter',
  17. 'instagram',
  18. 'youtube'
  19. ];
  20. public function advs()
  21. {
  22. return $this->hasMany('App\PageAdv');
  23. }
  24. public function getAdvs()
  25. {
  26. $advs['Sopra 234x60 1'] = array();
  27. $advs['Sopra 234x60 2'] = array();
  28. $advs['Sopra 234x60 3'] = array();
  29. $advs['Sopra 234x60 4'] = array();
  30. $advs['Sotto 234x60 1'] = array();
  31. $advs['Sotto 234x60 2'] = array();
  32. $advs['Sotto 234x60 3'] = array();
  33. $advs['Sotto 234x60 4'] = array();
  34. $advs['728x90'] = array();
  35. $pages_advs = $this->advs()->where('online', '=', true)->orderBy('sort')->get();
  36. foreach($pages_advs as $a)
  37. {
  38. $advs[$a->position][] = $a;
  39. }
  40. return $advs;
  41. }
  42. }