i use 3 array to store in table courses. please help me to save array in string or save array in database...my problem with array:
1- i cant store and save image in database
2-i cant save array outcomes and requirements in database
<div class="col-md-10"><input type="file" class="form-control" name="images" id="images" ></div>
//and this
<input type="text" class="form-control" name="outcomes[]" id="outcomes">
//or this
<input type="text" class="form-control" name="requirements[]" id="requirements">
my store function call:
public function store(CourseRequest $request)
{
$imageUrl = $this->upload2Images($request->file('images'));
auth()->user()->course()->create( $request->except(['_token','files']),['images'=>$imageUrl]);
return redirect(route('courses.index'));
}
and uploadImages is
public function upload2Images($file)
{
$year = Carbon::now()->year;
$month = Carbon::now()->month;
$imagePath = "upload/images/{$year}/{$month}/";
$filename = $file->getClientOriginalName();
$file = $file->move(public_path($imagePath), $filename);
$url['images'] = "upload/images/{$year}/{$month}/$filename";
return $url;
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire