|
|
@@ -14,6 +14,7 @@ class Post { |
|
|
|
|
|
|
|
// related |
|
|
|
public User $user; |
|
|
|
public $ratings = []; |
|
|
|
|
|
|
|
public static function unwrap($post) |
|
|
|
{ |
|
|
@@ -23,13 +24,16 @@ class Post { |
|
|
|
$s->date = Carbon::parse($post->createdAt)->format('d/m/Y H:i'); |
|
|
|
$s->content = $post->content; |
|
|
|
|
|
|
|
//$s->content = '[quote mentionsUser="1427" postId="659032" threadPage="1" threadId="19764" username="Dr. Magnusson"][/quote]'; |
|
|
|
|
|
|
|
// grab user if available |
|
|
|
if (isset($post->user)) { |
|
|
|
$s->user = User::unwrap($post->user); |
|
|
|
} |
|
|
|
|
|
|
|
// grab ratings if available |
|
|
|
$s->ratings = array_map(function($rating) { |
|
|
|
return Rating::unwrap($rating); |
|
|
|
}, $post->ratings ?? []); |
|
|
|
|
|
|
|
return $s; |
|
|
|
} |
|
|
|
|
|
|
|