Home.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <?php
  2. namespace App;
  3. use App\News;
  4. use Illuminate\Database\Eloquent\Model;
  5. class Home extends Model
  6. {
  7. protected $table = 'home';
  8. protected $fillable = [
  9. 'slide1',
  10. 'slide2',
  11. 'slide3',
  12. 'slide4',
  13. 'slide5',
  14. 'left',
  15. 'left1',
  16. 'left2',
  17. 'left3',
  18. 'left4',
  19. 'left5',
  20. 'right',
  21. 'right1',
  22. 'right2',
  23. 'right3',
  24. 'right4',
  25. 'right5',
  26. 'image',
  27. 'url',
  28. 'banner_top',
  29. 'banner_top_url',
  30. 'banner_top_google',
  31. 'banner_middle',
  32. 'banner_middle_url',
  33. 'banner_middle_google',
  34. 'banner_first',
  35. 'banner_first_url',
  36. 'banner_first_google',
  37. 'radio1_url',
  38. 'radio2_url',
  39. 'radio3_url',
  40. 'radio1_file',
  41. 'radio2_file',
  42. 'radio3_file',
  43. 'radio1_title',
  44. 'radio2_title',
  45. 'radio3_title',
  46. 'image_2',
  47. 'image_3',
  48. 'url_2',
  49. 'url_3',
  50. 'banner_underb',
  51. 'banner_underb_url',
  52. 'banner_underb_2',
  53. 'banner_underb_url_2',
  54. 'banner_underb_3',
  55. 'banner_underb_url_3',
  56. 'banner_underb_4',
  57. 'banner_underb_url_4',
  58. 'banner_underb_5',
  59. 'banner_underb_url_5',
  60. 'banner_underb_google',
  61. 'banner_top_2',
  62. 'banner_top_2_url',
  63. 'banner_middle_2',
  64. 'banner_middle_2_url',
  65. 'banner_first_2',
  66. 'banner_first_2_url',
  67. 'banner_top_3',
  68. 'banner_top_3_url',
  69. 'banner_top_4',
  70. 'banner_top_4_url',
  71. 'banner_top_5',
  72. 'banner_top_5_url',
  73. 'banner_middle_3',
  74. 'banner_middle_3_url',
  75. 'banner_middle_4',
  76. 'banner_middle_4_url',
  77. 'banner_middle_5',
  78. 'banner_middle_5_url',
  79. 'banner_first_3',
  80. 'banner_first_3_url',
  81. 'banner_first_4',
  82. 'banner_first_4_url',
  83. 'banner_first_5',
  84. 'banner_first_5_url',
  85. 'banner_right_top',
  86. 'banner_right_top_url',
  87. 'banner_right_top_2',
  88. 'banner_right_top_2_url',
  89. 'banner_right_top_3',
  90. 'banner_right_top_3_url',
  91. 'banner_right_top_4',
  92. 'banner_right_top_4_url',
  93. 'banner_right_top_5',
  94. 'banner_right_top_5_url',
  95. 'banner_right_top_google',
  96. 'banner_right_bottom',
  97. 'banner_right_bottom_url',
  98. 'banner_right_bottom_2',
  99. 'banner_right_bottom_2_url',
  100. 'banner_right_bottom_3',
  101. 'banner_right_bottom_3_url',
  102. 'banner_right_bottom_4',
  103. 'banner_right_bottom_4_url',
  104. 'banner_right_bottom_5',
  105. 'banner_right_bottom_5_url',
  106. 'banner_right_bottom_google',
  107. 'banner_right_middle',
  108. 'banner_right_middle_url',
  109. 'banner_right_middle_2',
  110. 'banner_right_middle_2_url',
  111. 'banner_right_middle_3',
  112. 'banner_right_middle_3_url',
  113. 'banner_right_middle_4',
  114. 'banner_right_middle_4_url',
  115. 'banner_right_middle_5',
  116. 'banner_right_middle_5_url',
  117. 'banner_right_middle_google',
  118. 'banner_right_big',
  119. 'banner_right_big_url',
  120. 'banner_right_big_2',
  121. 'banner_right_big_2_url',
  122. 'banner_right_big_3',
  123. 'banner_right_big_3_url',
  124. 'banner_right_big_4',
  125. 'banner_right_big_4_url',
  126. 'banner_right_big_5',
  127. 'banner_right_big_5_url',
  128. 'banner_right_big_google',
  129. 'footer_image',
  130. 'footer_image_2',
  131. 'footer_image_3',
  132. 'footer_url',
  133. 'footer_url_2',
  134. 'footer_url_3',
  135. ];
  136. function loadData()
  137. {
  138. $this->data = $this;
  139. if ($this->slide1 != '')
  140. $this->slide1 = @News::where('id', '=', $this->slide1)->first();
  141. if ($this->slide2 != '')
  142. $this->slide2 = @News::where('id', '=', $this->slide2)->first();
  143. if ($this->slide3 != '')
  144. $this->slide3 = @News::where('id', '=', $this->slide3)->first();
  145. if ($this->slide4 != '')
  146. $this->slide4 = @News::where('id', '=', $this->slide4)->first();
  147. if ($this->slide5 != '')
  148. $this->slide5 = @News::where('id', '=', $this->slide5)->first();
  149. if ($this->left != '')
  150. $this->left = @News::where('id', '=', $this->left)->first();
  151. if ($this->left1 != '')
  152. $this->left1 = @News::where('id', '=', $this->left1)->first();
  153. if ($this->left2 != '')
  154. $this->left2 = @News::where('id', '=', $this->left2)->first();
  155. if ($this->left3 != '')
  156. $this->left3 = @News::where('id', '=', $this->left3)->first();
  157. if ($this->left4 != '')
  158. $this->left4 = @News::where('id', '=', $this->left4)->first();
  159. if ($this->left5 != '')
  160. $this->left5 = @News::where('id', '=', $this->left5)->first();
  161. if ($this->right1 != '')
  162. $this->right1 = @News::where('id', '=', $this->right1)->first();
  163. if ($this->right2 != '')
  164. $this->right2 = @News::where('id', '=', $this->right2)->first();
  165. if ($this->right3 != '')
  166. $this->right3 = @News::where('id', '=', $this->right3)->first();
  167. if ($this->right4 != '')
  168. $this->right4 = @News::where('id', '=', $this->right4)->first();
  169. if ($this->right5 != '')
  170. $this->right5 = @News::where('id', '=', $this->right5)->first();
  171. }
  172. function hasSlider($type)
  173. {
  174. $tot = 0;
  175. if ($type == 'left')
  176. {
  177. if(isset($this->left1) && $this->left1 != '')
  178. $tot += 1;
  179. if(isset($this->left2) && $this->left2 != '')
  180. $tot += 1;
  181. if(isset($this->left3) && $this->left3 != '')
  182. $tot += 1;
  183. if(isset($this->left4) && $this->left4 != '')
  184. $tot += 1;
  185. if(isset($this->left5) && $this->left5 != '')
  186. $tot += 1;
  187. }
  188. if ($type == 'right')
  189. {
  190. if(isset($this->right1) && $this->right1 != '')
  191. $tot += 1;
  192. if(isset($this->right2) && $this->right2 != '')
  193. $tot += 1;
  194. if(isset($this->right3) && $this->right3 != '')
  195. $tot += 1;
  196. if(isset($this->right4) && $this->right4 != '')
  197. $tot += 1;
  198. if(isset($this->right5) && $this->right5 != '')
  199. $tot += 1;
  200. }
  201. return $tot > 1;
  202. }
  203. }