Completed
Pull Request — master (#83)
by Sebastian
04:16
created

ArticleRepository::getTopLevel()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace App\Repositories;
4
5
use App\Models\Article;
6
use App\Models\Enums\SpecialArticle;
7
use Illuminate\Support\Collection;
8
9
class ArticleRepository
10
{
11
    public function getTopLevel(): Collection
12
    {
13
        return Article::all()
14
            ->whereNull('parent_id')
15
            ->orderBy('order_column')
16
            ->get();
17
    }
18
19
    public function getSiblings(Article $article): Collection
20
    {
21
        return Article::all()
22
            ->where('parent_id', $article->parent_id)
23
            ->orderBy('order_column')
24
            ->get();
25
    }
26
27
    public function firstChild(Article $article): Article
28
    {
29
        return Article::all()
30
            ->where('parent_id', $article->id)
31
            ->orderBy('order_column')
32
            ->first();
33
    }
34
35
    /**
36
     * @param \App\Models\Enums\SpecialArticle $specialArticle
37
     *
38
     * @return \App\Models\Article|null
39
     */
40
    public function findSpecialArticle(SpecialArticle $specialArticle)
41
    {
42
        return $this->query()->where('technical_name', $specialArticle)->first();
0 ignored issues
show
Bug introduced by
The method query() does not seem to exist on object<App\Repositories\ArticleRepository>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
43
    }
44
}
45