функция обновления каркаса laravel
public function update(Request $request, $id)
{
if(isset($_POST['commer']))
{
$commercial = BestCommercialPhoto::findOrFail($id);
$input = $request->all();`enter code here`
if($file = $request->file('file'))
{
$name = time().$file->getClientOriginalName();
$file->move('images',$name);
$input['file'] = $name;
}
$commercial->update($input);
}
elseif(isset($_POST['fash']))
{
$fashion = BestFashionPhoto::findOrFail($id);
if($file = $request->file('file')){
$name = time().$file->getClientOriginalName();
$file->move('images',$name);
$input['file'] = $name;
}
$fashion->update($input);
}
elseif(isset($_POST['wed']))
{
$wedding = BestWeddingPhoto::findOrFail($id);
if($file = $request->file('file')) {
$name = time().$file->getClientOriginalName();
$file->move('images',$name);
$input['file'] = $name;
}
$wedding->update($input);
}
elseif(isset($_POST['make']))
{
$making = BestMakingPhoto::findOrFail($id);
if($file = $request->file('file'))
{
$name = time().$file->getClientOriginalName();
$file->move('images',$name);
$input['file'] = $name;
}
$making->update($input);
}
else
{
return "Not Working Properly";
}
}
Это код для редактирования общедоступной функции edit ($ id) {$ commercial = BestCommercialPhoto :: findOrFail ($ id);обратный просмотр («admin.bestPhoto.edit_comm», компактный («коммерческий»));}
Ниже приведен HTML-код для страницы редактирования.Я не могу обновить, если я нажимаю на 2-й строке, которая содержит [введите описание изображения здесь] [1] 4 изображения категории моды.Если я щелкну, чтобы обновить изображение категории «Мода», отобразится изображение 1-й строки, как обновить изображения из разных строк
<form method="post" action="/admin/bestPhoto/{{$commercial->id}}" enctype="multipart/form-data">
<input type="hidden" name="_method" value="PATCH">
{{ csrf_field()}}
<div class="card shadow-lg">
<div class="card-body">
<div class="form-group">
<div class="text-center">
<img class="img-fluid" src="/images/{{$commercial->file}}">
</div>
</div>
<div class="form-group">
<div class="text-center">
<input type="file" name="file" required>
</div>
</div>
<div class="form-group" style="width:25%">
<div class="text-center" >
<button name="commer" class="btn btn-outline-primary" type="submit"
style="width: 50%;">Save
</button>
</div>
</div>
</div>
</div>
</form>