'datetime', ]; /** * Delete this posts tags */ public function deleteTags() { $tags_to_delete = PostsTag::where('post_id', $this->id)->get(); foreach ($tags_to_delete as $tag_to_delete) { $tag_to_delete->delete(); } } public static function getUserPostForMonth($user_id, $year, $month) { return self::whereMonth('date_post', $month) ->whereYear('date_post', $year) ->where('user_id', $user_id) ->orderBy('date_post') ->get(); } }