Commit 1731c988 authored by ZeMKI's avatar ZeMKI

Update HomeController.php

parent b9e724ef
......@@ -6,7 +6,6 @@ use App\Helpers\NewsletterStatus;
use Auth;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\View\Factory;
use Illuminate\Http\Response;
use Illuminate\View\View;
use Session;
......@@ -28,7 +27,14 @@ class HomeController extends Controller
public function index()
{
$data['studies'] = Auth::user()->studies;
$data['newsletter'] = Auth::user()->profile->newsletter === config('enums.newsletter_status.NOT DECIDED');
if (auth()->user()->profile()->exists())
{
$data['newsletter'] = Auth::user()->profile->newsletter === config('enums.newsletter_status.NOT DECIDED');
} else
{
$profile = auth()->user()->addProfile(auth()->user());
$data['newsletter'] = Auth::user()->profile->newsletter === config('enums.newsletter_status.NOT DECIDED');
}
return view('home', $data);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment