Skip to content

Commit dc9049a

Browse files
coolio85Coolio85
andauthored
Add event meetup date (#55)
* Add event meetup date to model * Update test * Update fixtures * Fix failing check regarding cs * Update fixtures to be complete * Add missing event index fixtures --------- Co-authored-by: Coolio85 <[email protected]>
1 parent c0868af commit dc9049a

File tree

6 files changed

+32
-0
lines changed

6 files changed

+32
-0
lines changed

src/Models/Event.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ class Event extends Model
7878
*/
7979
protected Carbon $startAt;
8080

81+
/**
82+
* The event meetup date.
83+
*
84+
* @var Carbon|null
85+
*/
86+
protected ?Carbon $meetupAt;
87+
8188
/**
8289
* The event banner.
8390
*
@@ -216,6 +223,10 @@ public function __construct(Client $client, array $event)
216223
);
217224

218225
$this->startAt = new Carbon($this->getValue('start_at'), 'UTC');
226+
227+
$meetupAt = $this->getValue('meetup_at');
228+
$this->meetupAt = $meetupAt ? new Carbon($meetupAt, 'UTC') : null;
229+
219230
$this->banner = $this->getValue('banner');
220231
$this->map = $this->getValue('map');
221232
$this->description = $this->getValue('description');
@@ -346,6 +357,16 @@ public function getStartAt(): Carbon
346357
return $this->startAt;
347358
}
348359

360+
/**
361+
* Get the start date of the event.
362+
*
363+
* @return Carbon|null
364+
*/
365+
public function getMeetupAt(): ?Carbon
366+
{
367+
return $this->meetupAt;
368+
}
369+
349370
/**
350371
* Get the banner of the event.
351372
*

tests/Unit/Models/EventTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ public function testItHasAStartDate()
106106
$this->assertDate('2023-01-04 14:32:28', $this->event->getStartAt());
107107
}
108108

109+
public function testItHasAMeetupDate()
110+
{
111+
$this->assertDate('2023-01-04 14:02:28', $this->event->getMeetupAt());
112+
}
113+
109114
public function testItHasABanner()
110115
{
111116
$this->assertSame('https://static.truckersmp.com/images/event/cover/cover.png', $this->event->getBanner());

tests/Unit/Models/fixtures/event.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"city": "Stuttgart"
2222
},
2323
"start_at": "2023-01-04 14:32:28",
24+
"meetup_at": "2023-01-04 14:02:28",
2425
"banner": "https://static.truckersmp.com/images/event/cover/cover.png",
2526
"map": "https://static.truckersmp.com/images/event/map/map.png",
2627
"description": "Description",

tests/Unit/Requests/fixtures/event.index.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"city": "Stuttgart"
2626
},
2727
"start_at": "2023-01-15 19:00:00",
28+
"meetup_at": "2023-01-15 18:00:00",
2829
"banner": "https://static.truckersmp.com/images/event/cover/cover.jpeg",
2930
"map": "https://static.truckersmp.com/images/event/map/map.png",
3031
"description": "Description",
@@ -75,6 +76,7 @@
7576
"city": "Stuttgart"
7677
},
7778
"start_at": "2023-01-04 17:00:00",
79+
"meetup_at": "2023-01-04 16:00:00",
7880
"banner": "https://static.truckersmp.com/images/event/cover/cover.png",
7981
"map": "https://static.truckersmp.com/images/event/map/map.jpeg",
8082
"description": "",
@@ -127,6 +129,7 @@
127129
"city": "Dover"
128130
},
129131
"start_at": "2023-01-07 13:00:00",
132+
"meetup_at": "2023-01-07 12:00:00",
130133
"banner": "https://static.truckersmp.com/images/event/cover/cover.jpeg",
131134
"map": "https://static.truckersmp.com/images/event/map/map.png",
132135
"description": "Description",

tests/Unit/Requests/fixtures/event.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"city": "Stuttgart"
2424
},
2525
"start_at": "2023-01-04 14:32:28",
26+
"meetup_at": "2023-01-04 14:02:28",
2627
"banner": "https://static.truckersmp.com/images/event/cover/cover.png",
2728
"map": "https://static.truckersmp.com/images/event/map/map.png",
2829
"description": "Description",

tests/Unit/Requests/fixtures/event.user.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"city": "Verona"
2525
},
2626
"start_at": "2023-02-19 18:30:00",
27+
"meetup_at": "2023-02-19 18:00:00",
2728
"banner": "https://static.truckersmp.com/images/event/cover/cover.png",
2829
"map": "https://static.truckersmp.com/images/event/map/map.png",
2930
"description": "Description",

0 commit comments

Comments
 (0)