I want to create a setup which allows to setup a platfom and the first step consists on defining langs which will be used in the platform...
For this i created 2 routes :
Route::get('/home/setup', 'BackOffice\FirstconnectionController@initLang');
Route::patch('/home/setup', 'BackOffice\FirstconnectionController@initLangUpdate')->name('setup.setLang');
The first one call the initLang method which displays the list of langs which are trashed (i use softdeletes for this...). By default all languages have a timestamp in the deleted_at field.
public function initLang()
{
$langs = Lang::onlyTrashed()->get();
$sectorsCount = Sector::count();
return view('admin.firstConnection', compact('langs', 'sectorsCount'));
}
In my view :
{!! Form::model($langs, [
'method' => 'PATCH',
'route' => 'setup.setLang'
]) !!}
@foreach($langs as $lang)
{!! Form::label($lang->langname, $lang->langname ) !!}
{!! Form::checkbox( 'lang[]', $lang->id ) !!}
@endforeach
<div class="col-xs-12 col-sm-12 col-md-12 text-center">
<button type="submit" class="btn btn-primary">OK</button>
</div>
{!! Form::close() !!}
Finally the form is sent and i recover the data in the initLangUpdate() method
public function initLangUpdate(Request $request) {
$request = $request->input('lang');
return $request;
}
My problem is the following :
- I get an array of string : ["3","4"] and i should have an array of integer
- How do i manage to make my update in my table ? In fact the update should be to set deleted_at to NULL
- Is there another way to get the datas : i recover the values with an array : lang[]
Thanks
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire