diff --git a/app/Models/Actie.php b/app/Models/Actie.php
index 6426d1a7..ceeeaab7 100755
--- a/app/Models/Actie.php
+++ b/app/Models/Actie.php
@@ -50,6 +50,7 @@ class Actie extends Model
*/
protected $appends = [
'link',
+ 'afgelopen',
'start_end',
'start_unix',
'_geoloc',
@@ -226,21 +227,20 @@ public function report()
return $this->hasOne(Report::class)->without('actie');
}
- public function getAfgelopenAttribute()
- {
- return Date::parse($this->end_date . " " . $this->end_time)->timestamp < time();
- }
-
public function getPublishedAttribute()
{
return $this->status === "PUBLISHED";
}
-
- public function scopePublished($query)
+
+ public function getAfgelopenAttribute()
{
- return $query->where('status', 'PUBLISHED');
+ if ($this->end_time === null) {
+ // if end_time is not set, take the end of the day
+ return Date::parse($this->end_date . " " . "23:59:59")->timestamp < time();
+ }
+ return Date::parse($this->end_date . " " . $this->end_time)->timestamp < time();
}
-
+
public function scopeNietAfgelopen($query)
{
// check if end_time is defined
@@ -248,6 +248,11 @@ public function scopeNietAfgelopen($query)
->orWhereRaw("(end_time is NULL AND STR_TO_DATE(end_date, '%Y-%m-%d') >= '" . Date::now()->toDateString() . "')");
}
+ public function scopePublished($query)
+ {
+ return $query->where('status', 'PUBLISHED');
+ }
+
public function publish()
{
$this->status = 'PUBLISHED';
diff --git a/resources/views/assets/js/components/partials/Actie.vue b/resources/views/assets/js/components/partials/Actie.vue
index ddcdadb6..09a000fb 100644
--- a/resources/views/assets/js/components/partials/Actie.vue
+++ b/resources/views/assets/js/components/partials/Actie.vue
@@ -3,7 +3,7 @@
class="flex flex-col overflow-hidden rounded-lg shadow-lg actie relative transition-all ease-out hover:translate-y-[-0.250rem] hover:shadow-[0_0_20px_rgba(0,0,0,0.30)]"
typeof="Article"
>
-
+
@@ -128,11 +128,6 @@ export default {
type: Object,
required: true,
}
- },
- computed: {
- isAfgelopen() {
- return new Date(this.actie.end_date + " " + this.actie.end_time) < new Date()
- }
}
}