Issues (97)

app/Services/BlogThemeServices.php (7 issues)

1
<?php
2
3
namespace App\Services;
4
5
use App\Models\BlogSetting;
6
use App\Models\Theme;
7
8
class BlogThemeServices
9
{
10
    /**
11
     * Return the blog theme.
12
     *
13
     * @param string $text
14
     *
15
     * @return string
16
     */
17
    public static function getBlogTheme()
18
    {
19
        $self = new self();
20
21
        return Theme::find($self->getBlogThemeId());
22
    }
23
24
    /**
25
     * Returns the blog theme identifier.
26
     *
27
     * @return string
28
     */
29
    public function getBlogThemeId()
30
    {
31
        return BlogSetting::themeId()->pluck('value')->first();
32
    }
33
34
    /**
35
     * Gets a theme.
36
     *
37
     * @param int$id
38
     *
39
     * @return colletion.
0 ignored issues
show
Documentation Bug introduced by
The doc comment colletion. at position 0 could not be parsed: Unknown type name 'colletion.' at position 0 in colletion..
Loading history...
40
     */
41
    public static function getTheme($id)
42
    {
43
        return Theme::findOrFail($id);
44
    }
45
46
    /**
47
     * Gets all themes.
48
     *
49
     * @return collection
0 ignored issues
show
The type App\Services\collection was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
50
     */
51
    public static function getAllThemes()
52
    {
53
        return Theme::orderBy('name', 'asc')->get();
0 ignored issues
show
Bug Best Practice introduced by
The expression return App\Models\Theme:...y('name', 'asc')->get() also could return the type Illuminate\Database\Eloquent\Collection which is incompatible with the documented return type App\Services\collection.
Loading history...
54
    }
55
56
    /**
57
     * Stores a new theme.
58
     *
59
     * @param $validatedRequest  The validated request
0 ignored issues
show
The type App\Services\The was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
60
     *
61
     * @return collection
62
     */
63
    public static function storeNewTheme($validatedRequest)
64
    {
65
        $taggableBase = [
66
            'taggable_id'     => 0,
67
            'taggable_type'   => 'theme',
68
        ];
69
70
        $theme = Theme::create(array_merge($validatedRequest, $taggableBase));
71
        $theme->taggable_id = $theme->id;
72
        $theme->save();
73
74
        return $theme;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $theme returns the type App\Models\Theme which is incompatible with the documented return type App\Services\collection.
Loading history...
75
    }
76
77
    /**
78
     * Update the default theme in the settings.
79
     *
80
     * @param int $themeId The theme identifier
81
     *
82
     * @return collection
83
     */
84
    public static function updateDefaultThemeSetting($themeId)
85
    {
86
        $blogTheme = BlogSetting::where('key', '=', 'blog_theme_id')->first();
87
        $blogTheme->value = $themeId;
88
        $blogTheme->save();
89
90
        return $blogTheme;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $blogTheme also could return the type App\Models\BlogSetting which is incompatible with the documented return type App\Services\collection.
Loading history...
91
    }
92
93
    /**
94
     * Delete a blgo theme.
95
     *
96
     * @param int $themeId
97
     *
98
     * @return collection
99
     */
100
    public static function deleteBlogTheme($themeId)
101
    {
102
        $theme = Theme::findOrFail($themeId);
103
        $theme->delete();
104
105
        return $theme;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $theme returns the type App\Models\Theme which is incompatible with the documented return type App\Services\collection.
Loading history...
106
    }
107
}
108