From 81833aa60797eed34f0c8892e4eb8fdaf9366dba Mon Sep 17 00:00:00 2001 From: Louis Jeckel Date: Fri, 4 Sep 2020 11:59:15 +0200 Subject: [PATCH] Update WeeklyAgenda.php --- app/Models/WeeklyAgenda.php | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/app/Models/WeeklyAgenda.php b/app/Models/WeeklyAgenda.php index 0e5da81..f268840 100644 --- a/app/Models/WeeklyAgenda.php +++ b/app/Models/WeeklyAgenda.php @@ -37,16 +37,42 @@ class WeeklyAgenda extends Model ], ]; + /** + * @return string + */ public function getTitleAttribute() { - return $this->start_date; + return $this->start_date->format('d/m/Y'); } + /** + * @return Carbon + */ public function getEndDateAttribute(): Carbon { return $this->start_date->addWeek(); } + public function getUrlAttribute() + { + return route('agenda.show', ['agenda' => $this->id]); + } + + + + public function nextWeekUrl() + { + return ($a = self::find($this->id + 1)) === null ? + null : + $a->url; + } + + public function lastWeekUrl() + { + return ($a = self::find($this->id - 1)) === null ? + null : + $a->url; + } } -- 2.39.5