1 | <?php |
||
2 | |||
3 | namespace App\Http\ViewComposers; |
||
4 | |||
5 | use App\Models\Theme; |
||
6 | use Illuminate\Support\Facades\Auth; |
||
7 | use Illuminate\View\View; |
||
8 | |||
9 | class ThemeComposer |
||
10 | { |
||
11 | protected $user; |
||
12 | protected $theme; |
||
13 | |||
14 | public function __construct() |
||
15 | { |
||
16 | $this->user = Auth::user(); |
||
17 | } |
||
18 | |||
19 | /** |
||
20 | * Bind data to the view. |
||
21 | * |
||
22 | * @param View $view |
||
23 | * |
||
24 | * @return void |
||
25 | */ |
||
26 | public function compose(View $view) |
||
27 | { |
||
28 | $theme = null; |
||
29 | |||
30 | if (Auth::check()) { |
||
31 | $user = $this->user; |
||
32 | |||
33 | if ($user->profile) { |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
34 | $theme = Theme::find($user->profile->theme_id); |
||
35 | |||
36 | if ($theme->status == 0) { |
||
37 | $theme = Theme::find(1); |
||
38 | } |
||
39 | } |
||
40 | } |
||
41 | |||
42 | $view->with('theme', $theme); |
||
43 | } |
||
44 | } |
||
45 |