'array', ]; public function user() { return $this->belongsTo('App\User'); } public function pictures() { return $this->morphMany('App\Picture', 'pictureable'); } public function logs() { return $this->morphMany('App\Log', 'logable'); } public static function allWithWeeklyMsg() { $news = \App\News::all(); foreach (\App\Event::all() as $event) { if($event->use_weekly_msg == 1) { $news->push(self::getWeeklyMsg($event)); } } return $news; } public static function getWeeklyMsg(\App\Event $event) { $n = new News(); $n->event_id = $event->id; $n->title = 'Message de la semaine du '.date('Y-m-d',strtotime($event->date_begin)); $n->body = $event->desc; $n->user_id = $event->user_id; $n->publish = 1; $n->created_at = $event->created_at; $n->updated_at = $event->updated_at; $n->tags = ['message de la semaine','Important']; if ($event->weekly_msg_file != null) { $n->files = $event->weekly_msg_file; } return $n; } }