在设置过程中,我想:
为此,我创建了3条路线。
Route::get('/home/setup', 'BackOffice\FirstconnectionController@initLang');
Route::patch('/home/setup', 'BackOffice\FirstconnectionController@initLangUpdate')->name('setup.setLang');
Route::patch('/home/setup', 'BackOffice\FirstconnectionController@setDefaultLang')->name('setup.setDefaultLang');
以下是我的观点:
@if ($message = Session::get('success'))
<div class="alert alert-success">
<p>{{ $message }}</p>
</div>
@endif
{{-- IF NO LANGS ARE PUBLISHED I CAN CHOOSE HERE --}}
@if ($langsCount == 0)
{!! Form::model($langs, [
'method' => 'PATCH',
'route' => 'setup.setLang'
])
!!}
@foreach($langs as $lang)
<div class="form-group">
{{--<label class="col-md-4"> {{ $lang->langname }} </label>--}}
{{--<input id="{{ $lang->langisocode }}" type="checkbox">--}}
{!! Form::label($lang->langname, $lang->langname ) !!}
{!! Form::checkbox( 'lang[]', $lang->id ) !!}
</div>
@endforeach
<div class="col-xs-12 col-sm-12 col-md-12 text-center">
<button type="submit" class="btn btn-primary">Valider</button>
</div>
{!! Form::close() !!}
{{-- NOW I SELECT DEFAULT LANGUAGE... --}}
@else
{!! Form::model($langs, [
'method' => 'PATCH',
'route' => 'setup.setDefaultLang'
])
!!}
@foreach($pubLangs as $pubLang)
{!! Form::label($pubLang->langname, $pubLang->langname ) !!}
{!! Form::radio( 'lang', $pubLang->id ) !!}
<br>
@endforeach
<div class="col-xs-12 col-sm-12 col-md-12 text-center">
<button type="submit" class="btn btn-primary">Valider</button>
</div>
{!! Form::close() !!}
@endif
这是我的控制器:
// I display the info here
public function initLang()
{
$langs = Lang::onlyTrashed()->get();
$langsCount = Lang::count();
$pubLangs = Lang::all();
return view('admin.firstConnection', compact('langs', 'langsCount', 'pubLangs'));
}
public function initLangUpdate(Request $request) {
$request = $request->input('lang');
foreach ($request as $entry) {
Lang::withTrashed()->find($entry)->restore();
}
return redirect('admin/home/setup')->with('success', 'OK');
}
public function setDefaultLang(Request $request) {
$request = $request->input('lang');
return $request;
}
我将在...之后更新setDefaultLang 我有这个错误消息: 路线[setup.setLang]未定义