When trying to update or fetch data on edit page getting bellow issue Invalid argument supplied for foreach() in the Form::select() area.
Below is my controller :
if (!$_POST) {
$bedrooms = ["studio"];
$bedrooms[0] = "Studio";
$i = 1;
while ($i < 10) {
$beds = [];
$i = 1;
while ($i < 16) {
$bathrooms = [];
$bathrooms[0] = 0;
$i = 0;
while ($i < 8) {
$accommodates = [];
$i = 1;
while ($i < 16) {
$data["bedrooms"] = ["studio"];
$data["beds"] = [1,2,3,4,5,6, 7,8,9,10,11,12,13,14,15,"16+"];
$data["bed_type"] = \App\Models\BedType::where("status", "Active")->pluck("name", "id");
$data["bathrooms"] = [1,2,3,4,5,6,7,"8+"];
$data["property_type"] = \App\Models\PropertyType::where("status", "Active")->pluck("name", "id");
$data["room_type"] = \App\Models\RoomType::where("status", "Active")->pluck("name", "id");
$data["lan_description"] = \App\Models\RoomsDescriptionLang::where("room_id", $request->id)->get();
$data["accommodates"] = [0,1,2,3,4,5,6, 7,8,9,10,11,12,13,14,15,"16+"];
$data["country"] = \App\Models\Country::pluck("long_name", "short_name");
$data["amenities"] = \App\Models\Amenities::active_all()->groupBy("type_id");
$data["users_list"] = \App\Models\User::pluck("first_name", "id");
$data["room_id"] = $request->id;
$data["result"] = \App\Models\Rooms::find($request->id);
// dd($data['result']);
$data["rooms_photos"] = \App\Models\RoomsPhotos::where("room_id", $request->id)->get();
$data["calendar"] = str_replace(["<form name=\"calendar-edit-form\">", "</form>", url("manage-listing/" . $request->id . "/calendar")], ["", "", "javascript:void(0);"], $calendar->generate($request->id));
$data["prev_amenities"] = explode(",", $data["result"]->amenities);
// dd($data["prev_amenities"]);
$data["length_of_stay_options"] = \App\Models\Rooms::getLenghtOfStayOptions();
$data["availability_rules_months_options"] = \App\Models\Rooms::getAvailabilityRulesMonthsOptions();
// dd($data);
return view("admin.rooms.edit", $data);
}
$accommodates[$i] = $i == 16 ? $i . "+" : $i;
$i++;
}
$bathrooms[(string) $i] = $i == 8 ? $i . "+" : $i;
$i += 0;
}
$beds[$i] = $i == 16 ? $i . "+" : $i;
$i++;
}
$bedrooms[$i] = $i;
$i++;
}
And view file as follows:
{!! Form::open(['url' => ADMIN_URL.'/edit_room/'.$room_id='', 'class' => 'form-horizontal', 'id' => 'add_room_form', 'files' => true]) !!}
<input type="hidden" value="" name="room_id" id="room_id">
<div id="sf1" class="frm">
<fieldset class="box-body">
<div id="ajax_container" class="iccon">
{!! $calendar??'' !!}
</div>
</fieldset>
</div>
<div id="sf2" class="frm">
<p class="text-danger">
(*)Fields are Mandatory
</p>
<fieldset class="box-body">
<p class="text-success text-bold">
Rooms and Beds
</p>
<div class="form-group">
<label for="bedrooms" class="col-sm-3 control-label">
Bedrooms
<em class="text-danger">
*
</em>
</label>
<div class="col-sm-6">
{!! Form::select('bedrooms', $bedrooms='', $result->bedrooms, ['class' => 'form-control', 'id' => 'bedrooms', 'placeholder' => 'Select...']) !!}
</div>
</div>
<div class="form-group">
<label for="beds" class="col-sm-3 control-label">
Beds
<em class="text-danger">
*
</em>
</label>
<div class="col-sm-6">
{!! Form::select('beds', $beds, $result->beds, ['class' => 'form-control', 'id' => 'beds', 'placeholder' => 'Select...']) !!}
</div>
</div>
<div class="form-group">
<label for="bed_type" class="col-sm-3 control-label">
Bed Type
<em class="text-danger">
*
</em>
</label>
<div class="col-sm-6">
{!! Form::select('bed_type', $bed_type, $result->bed_type, ['class' => 'form-control', 'id' => 'bed_type', 'placeholder' => 'Select...']) !!}
</div>
</div>
I am not getting what is wrong in that. in dd($result) getting all attributes values but not getting ehy this errors comes Current i am working on laravel5.5 version. ANyone have idea thwn please let me know
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3yORqJ3
via IFTTT
Aucun commentaire:
Enregistrer un commentaire