| @@ -105,8 +105,19 @@ | ||
| 105 | 105 | ]; |
| 106 | 106 | |
| 107 | 107 | public static $scopeType = 'text'; |
| 108 | 108 | |
| 109 | + /** | |
| 110 | + * The types a /post/{slug} URL can serve. | |
| 111 | + * | |
| 112 | + * fcom_posts is shared: it also holds course_lesson, course_section and | |
| 113 | + * space_page rows, and each of those owns a different route. Any lookup that | |
| 114 | + * drops the type global scope to reach image and article posts must narrow to | |
| 115 | + * this list, or a feed URL can answer with a lesson or a page that happens to | |
| 116 | + * share the slug. Add a new feed shape here when one is introduced. | |
| 117 | + */ | |
| 118 | + public static $feedViewTypes = ['text', 'image', 'article']; | |
| 119 | + | |
| 109 | 120 | public static function boot() |
| 110 | 121 | { |
| 111 | 122 | parent::boot(); |
| 112 | 123 | |
| @@ -155,9 +166,9 @@ | ||
| 155 | 166 | // get the first 40 char from the title |
| 156 | 167 | $title = mb_substr($title, 0, 40, 'UTF-8'); |
| 157 | 168 | } else { |
| 158 | 169 | // get the first 25 char from the message |
| 159 | - $title = mb_substr($newModel->message, 0, 40, 'UTF-8'); | |
| 170 | + $title = mb_substr((string) $newModel->message, 0, 40, 'UTF-8'); | |
| 160 | 171 | } |
| 161 | 172 | |
| 162 | 173 | $title = Helper::normalizeToAscii($title); |
| 163 | 174 | $title = remove_accents($title); |
| @@ -284,13 +295,12 @@ | ||
| 284 | 295 | ) { |
| 285 | 296 | return $query->whereIn('status', [ 'published', 'pending' ]); |
| 286 | 297 | } |
| 287 | 298 | |
| 288 | - // This is a normal User. | |
| 289 | - return $query->where(function ($q) use ($user) { | |
| 290 | - $q->where('status', 'published') | |
| 291 | - ->orWhere(function ($q) use ($user) { | |
| 292 | - $q->where('status', 'pending') | |
| 299 | + return $query->where(function ($statusQuery) use ($user) { | |
| 300 | + $statusQuery->where('status', 'published') | |
| 301 | + ->orWhere(function ($subQuery) use ($user) { | |
| 302 | + $subQuery->where('status', 'pending') | |
| 293 | 303 | ->where('user_id', $user->ID); |
| 294 | 304 | }); |
| 295 | 305 | }); |
| 296 | 306 | } |