Update settings view to display currently selected language
MODIFY
app/Http/Controllers/SettingsController.php
app/Http/Controllers/SettingsController.php
@@ -7,7 +7,9 @@ use Illuminate\Support\Facades\Auth;
class SettingsController extends Controller {
public function index() {
- return view('settings.index');
+ $languages = ['en', 'nl'];
+
+ return view('settings.index', compact('languages'));
}
public function store(Request $request) {

MODIFY
resources/views/settings/index.blade.php
resources/views/settings/index.blade.php
<input type="text" name="email" value="{{ Auth::user()->email }}" />
<label>Language</label>
<select name="language">
- <option value="en">English</option>
- <option value="nl">Nederlands</option>
+ @foreach ($languages as $language)
+ <option value="{{ $language }}" @if (Auth::user()->language === $language) selected @endif>{{ $language }}</option>
+ @endforeach
</select>
<button>Update</button>
</form>

Update settings view to display currently selected language