good I'm trying to upload multiple images but I get the following error, before saving the images and I cannot get the error, I have a list of properties to images of one to many
method store
public function store(Request $request)
{
/*--from this session you start to save the properties with all their attributes --*/
$properti = new Propertie;
$detail = new Detail;
$detail->antiquity = $request->antiquity;
$detail->furnished = $request->furnished;
$detail->floor = $request->floor;
$detail->save();
$properti->details_id = $detail->id;
$properti->name = $request->name;
$properti->price = $request->price;
$properti->description = $request->description;
$properti->departaments_id = $request->departaments;
$properti->municipalities_id = $request->municipalities;
$properti->property_type_id = $request->type_property;
$properti->offer_type_id = $request->type;
$properti->details_id = $detail->id;
$properti->lat = $request->lat;
$properti->lng = $request->lng;
$properti->address = $request->address;
if (isset($request->property_id)) {
$property_type = $request->property_id;
} else {
$property_type = null;
}
$properti->save();
foreach($images as $image){
$name=$image->getClientOriginalName();
$image->move('image',$name);
// create a new Image and relate it to the property
$property->images()->create(['name' => $name]);
}
$piso_id = $properti->id;
$space = new Space;
$space->property_id = $piso_id;
$space->bedrooms = $request->bedrooms;
$space->bathrooms = $request->bathrooms;
$space->parking = $request->parking;
$space->area = $request->area;
$space->save();
$properti->spaces_id = $space->id;
foreach ($request->input('characteristic') as $characteristic) {
$charc = new Characteristic;
$charc->property_id = $piso_id;
$charc->characteristic = $characteristic;
$charc->save();
}
Session::flash('message', 'Se ha registrado su propiedad De forma exitosa');
return redirect()->action('PropertyController@index');
// return view('properties.index',compact('properties'));
}
input file
<div class="custom-file">
<input required type="file" class="form-control" name="images[]" placeholder="Imagenes" multiple>
</div>
</div>
If you can help me solve it, I would appreciate it.
I have my table images
I need to save several images in my database, with the id of the publication
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire