A bare bones front-end for knockout designed for maximum compatibility with "obsolete" browsers
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.1KB

  1. <?php
  2. namespace App\Knockout;
  3. use Carbon\Carbon;
  4. class Ban {
  5. // meta
  6. public $id;
  7. public $createdAt;
  8. public $endsAt;
  9. public $reason;
  10. // related
  11. public Post $post;
  12. public Thread $thread;
  13. public User $creator;
  14. public User $user;
  15. public static function unwrap($ban)
  16. {
  17. $s = new self();
  18. $s->id = $ban->id;
  19. $s->createdAt = Carbon::parse($ban->createdAt)->format('d/m/Y H:i');
  20. $s->endsAt = Carbon::parse($ban->expiresAt)->format('d/m/Y H:i');
  21. $s->reason = $ban->banReason;
  22. // grab user if available
  23. if (isset($ban->user)) {
  24. $s->user = User::unwrap($ban->user);
  25. }
  26. // grab creator if available
  27. if (isset($ban->bannedBy)) {
  28. $s->creator = User::unwrap($ban->bannedBy);
  29. }
  30. // grab thread if available
  31. if (isset($ban->thread)) {
  32. $s->thread = Thread::unwrap($ban->thread);
  33. }
  34. // grab post if available
  35. if (isset($ban->post)) {
  36. $s->post = Post::unwrap($ban->post);
  37. }
  38. return $s;
  39. }
  40. }