From b878740f80ce7cfe2a0bc53956e3f7e4e0aa2f78 Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Sun, 10 Nov 2019 21:30:26 +0100 Subject: News: Bug fixes, cleanup, comments & formatting Use more magically available methods and properties Fixed atom feed and stats not using the new model --- src/Controllers/Metrics/Stats.php | 9 ++------ src/Models/News.php | 45 +++++++++++++++++++++++++++++++++++++++ src/Models/News/News.php | 30 -------------------------- src/Models/User/User.php | 2 +- 4 files changed, 48 insertions(+), 38 deletions(-) create mode 100644 src/Models/News.php delete mode 100644 src/Models/News/News.php (limited to 'src') diff --git a/src/Controllers/Metrics/Stats.php b/src/Controllers/Metrics/Stats.php index af453cde..2d58f999 100644 --- a/src/Controllers/Metrics/Stats.php +++ b/src/Controllers/Metrics/Stats.php @@ -5,6 +5,7 @@ namespace Engelsystem\Controllers\Metrics; use Carbon\Carbon; use Engelsystem\Database\Database; use Engelsystem\Models\EventConfig; +use Engelsystem\Models\News; use Illuminate\Database\Query\Builder as QueryBuilder; use Illuminate\Database\Query\Expression as QueryExpression; @@ -209,16 +210,10 @@ class Stats /** * @param bool $meeting * @return int - * @codeCoverageIgnore */ public function announcements($meeting = null) { - $query = $this - ->getQuery('News'); - - if (!is_null($meeting)) { - $query->where('Treffen', '=', $meeting); - } + $query = is_null($meeting) ? News::query() : News::whereIsMeeting($meeting); return $query->count(); } diff --git a/src/Models/News.php b/src/Models/News.php new file mode 100644 index 00000000..55ab9c1d --- /dev/null +++ b/src/Models/News.php @@ -0,0 +1,45 @@ + 'boolean', + ]; + + /** @var array */ + protected $fillable = [ + 'title', + 'text', + 'is_meeting', + 'user_id', + ]; +} diff --git a/src/Models/News/News.php b/src/Models/News/News.php deleted file mode 100644 index ae67752b..00000000 --- a/src/Models/News/News.php +++ /dev/null @@ -1,30 +0,0 @@ - 'boolean', - ]; - - protected $attributes = [ - 'is_meeting' => false, - ]; - - protected $fillable = [ - 'title', - 'text', - 'is_meeting', - 'user_id', - ]; -} diff --git a/src/Models/User/User.php b/src/Models/User/User.php index cca96dbe..058f9a8c 100644 --- a/src/Models/User/User.php +++ b/src/Models/User/User.php @@ -4,7 +4,7 @@ namespace Engelsystem\Models\User; use Carbon\Carbon; use Engelsystem\Models\BaseModel; -use Engelsystem\Models\News\News; +use Engelsystem\Models\News; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasOne; use Illuminate\Database\Query\Builder as QueryBuilder; -- cgit v1.2.3-70-g09d2