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.
|
- <?php
-
- namespace App\Knockout;
-
- use Carbon\Carbon;
-
- class Ban {
-
- // meta
- public $id;
- public $createdAt;
- public $endsAt;
- public $reason;
-
- // related
- public Post $post;
- public Thread $thread;
- public User $creator;
- public User $user;
-
- public static function unwrap($ban)
- {
- $s = new self();
-
- $s->id = $ban->id;
- $s->createdAt = Carbon::parse($ban->createdAt)->format('d/m/Y H:i');
- $s->endsAt = Carbon::parse($ban->expiresAt)->format('d/m/Y H:i');
- $s->reason = $ban->banReason;
-
- // grab user if available
- if (isset($ban->user)) {
- $s->user = User::unwrap($ban->user);
- }
-
- // grab creator if available
- if (isset($ban->bannedBy)) {
- $s->creator = User::unwrap($ban->bannedBy);
- }
-
- // grab thread if available
- if (isset($ban->thread)) {
- $s->thread = Thread::unwrap($ban->thread);
- }
-
- // grab post if available
- if (isset($ban->post)) {
- $s->post = Post::unwrap($ban->post);
- }
-
- return $s;
- }
-
- }
|