| Total Complexity | 7 |
| Total Lines | 98 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 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. |
||
|
|
|||
| 40 | */ |
||
| 41 | public static function getTheme($id) |
||
| 42 | { |
||
| 43 | return Theme::findOrFail($id); |
||
| 44 | } |
||
| 45 | |||
| 46 | /** |
||
| 47 | * Gets all themes. |
||
| 48 | * |
||
| 49 | * @return collection |
||
| 50 | */ |
||
| 51 | public static function getAllThemes() |
||
| 52 | { |
||
| 53 | return Theme::orderBy('name', 'asc')->get(); |
||
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
| 57 | * Stores a new theme. |
||
| 58 | * |
||
| 59 | * @param $validatedRequest The validated request |
||
| 60 | * |
||
| 61 | * @return collection |
||
| 62 | */ |
||
| 63 | public static function storeNewTheme($validatedRequest) |
||
| 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; |
||
| 91 | } |
||
| 92 | |||
| 93 | /** |
||
| 94 | * Delete a blgo theme. |
||
| 95 | * |
||
| 96 | * @param int $themeId |
||
| 97 | * |
||
| 98 | * @return collection |
||
| 99 | */ |
||
| 100 | public static function deleteBlogTheme($themeId) |
||
| 106 | } |
||
| 107 | } |
||
| 108 |