Hai I can't update the image array in my repeater field. In my code if the user select template as "Custom" the repeater fields are displayed with add more button. Each block there will be three field contains one image field. If I update the field image always returns null. cant update the image field.Please help
What I have tried:
Here is my controller code
/* update template */
$datat = Input::all();
$id = $datat['id'];
if($last_updated_id!="")
{
$delete = DB::table('wd_templates')->where('page_id', $last_updated_id)->delete();
for($i = 0; $i < count($datat['template_desc']); $i++)
{
$imageName = str_random(3) . '.' .
$request->file('template_img')[$i]->getClientOriginalExtension();
$request->file('template_img')[$i]->move(base_path() . '/public/uploads/', $imageName);
$data1 = array(
'page_id' => $datat['id'],
'page_template' => $page_template,
'template_desc' => $datat['template_desc'][$i],
'template_img' => $imageName,
'tlink' => $datat['tlink'][$i],
'template_column' => $datat['template_column'][$i],
);
DB::table('wd_templates')->where('page_id', $id)->insert($data1);
}
}
}
\Session::flash('flash_message','Client has been added successfully!');
return Redirect::to('/admin/listpage')->with('pages');
Here is my view
@foreach($template as $data)
<select class="form-control" name="template_column[]">
<option>-- Select Layouts --</option>
for($c=1;$c<=12;$c++)
{
?>
<option value=""template_column == 'col-md-'.$c ) echo 'selected' ; ?> ></option>
}
?>
</select>
<input type="text" class="form-control" name="tlink[]" placeholder="Type something" value="{{$data->tlink}}">
<textarea class="form-control" name="template_desc[]" placeholder="Description" rows="5">{{$data->template_desc}}</textarea>
<input type="file" class="form-control" name="template_img[]" multiple="true" value="{{$data->template_img}}" /><img src="/uploads/{{$data->template_img}}" width="200" height="150" />
<!-- <input type="hidden" name="old" value="{{$data->template_img}}">-->
<button class="btn btn-success btn-add" type="button">
</button>
<button class="btn btn-danger btn-remove" type="button">
</button>
@endforeach