for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace App\Http\ViewComposers;
use App\Models\Theme;
use Illuminate\Support\Facades\Auth;
use Illuminate\View\View;
class ThemeComposer
{
protected $user;
protected $theme;
public function __construct()
$this->user = Auth::user();
}
/**
* Bind data to the view.
*
* @param View $view
* @return void
*/
public function compose(View $view)
$theme = null;
if (Auth::check()) {
$user = $this->user;
if ($user->profile) {
profile
Illuminate\Contracts\Auth\Authenticatable
instanceof
$theme = Theme::find($user->profile->theme_id);
if ($theme->status == 0) {
$theme = Theme::find(1);
$view->with('theme', $theme);