- Joined
- Oct 17, 2012
- Messages
- 660
- Reaction score
- 263
Здравейте,
искам да попитам как мога да направя само с 1 submit бутон да се ъпдейтват множество задачи идващи от цикъл(foreach). При Dumb and Die ми връща винаги първият резултат(1). Мерси предварително ; )
.blade.php
Controller
искам да попитам как мога да направя само с 1 submit бутон да се ъпдейтват множество задачи идващи от цикъл(foreach). При Dumb and Die ми връща винаги първият резултат(1). Мерси предварително ; )
.blade.php
Code:
@extends('layout.ap')
@section('content')
<!-- Content Wrapper. Contains page content -->
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<div class="container-fluid">
<div class="row mb-2">
<div class="col-sm-6">
<h1>Website management</h1>
</div>
<div class="col-sm-6">
<ol class="breadcrumb float-sm-right">
<li class="breadcrumb-item"><a href="#">Home</a></li>
<li class="breadcrumb-item active">Class Settings</li>
</ol>
</div>
</div>
</div><!-- /.container-fluid -->
</section>
<!-- Main content -->
<section class="content">
<div class="container-fluid">
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-header">
<h3 class="card-title">Edit Class Settings</h3>
</div>
<!-- /.card-header -->
<div class="card-body">
<table id="example2" class="table table-bordered table-hover">
<thead>
<tr>
<th>Class ID</th>
<th>Class Name</th>
<th>Short Name</th>
<th>Max Level</th>
<th>Points Per Level</th>
</tr>
</thead>
<tbody>
@foreach($char as $values)
<form method="post" action="/adminpanel/charclass">
{{csrf_field()}}
<tr>
<td>
<div class="col-4">
<input type="text" class="form-control" name="Personid[]" value="{{$values->id}}">
</div>
</td>
<td>
<div class="col-8">
<input type="text" class="form-control" name="classname[]" value="{{$values->classname}}">
</div>
</td>
<td>
<div class="col-8">
<input type="text" class="form-control" name="shortname[]" value="{{$values->shortname}}">
</div>
</td>
<td>
<div class="col-8">
<input type="text" class="form-control" name="maxlevel[]" value="{{$values->maxlevel}}">
</div>
</td>
<td>
<div class="col-8">
<input type="text" class="form-control" name="ppl[]" value="{{$values->ppl}}">
</div>
</td>
</tr>
@endforeach
</tbody>
<tfoot>
<tr>
<th>Class ID</th>
<th>Class Name</th>
<th>Short Name</th>
<th>Max Level</th>
<th>Points Per Level</th>
</tr>
</tfoot>
</table>
</div>
<div class="card-footer">
<button type="submit" class="btn btn-primary col-12">Submit</button>
</div>
</form>
<!-- /.card-body -->
</div>
<!-- /.card -->
</div>
<!-- /.col -->
</div>
<!-- /.row -->
</div>
<!-- /.container-fluid -->
</section>
<!-- /.content -->
</div>
<!-- /.content-wrapper -->
@endsection
Controller
Code:
public function do_charclass(Request $request)
{
foreach ($request->Personid as $key => $items)
{
$update = DB::connection('XXX')->table(XXX_CHARCLASS')
->where('Personid', $request->Personid[$key])
->update(
[
'classname' => $request->classname[$key],
'shortname' => $request->shortname[$key],
'maxlevel' => $request->maxlevel[$key],
'ppl' => $request->ppl[$key]
]);
dd($request->Personid[$key]);
return redirect('adminpanel/charclass');
}
}