Invalid argument supplied for foreach() in view page getting issue laravel5.5

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"] = AppModelsBedType::where("status", "Active")->pluck("name", "id");
$data["bathrooms"] = [1,2,3,4,5,6,7,"8+"];
$data["property_type"] = AppModelsPropertyType::where("status", "Active")->pluck("name", "id");
$data["room_type"] = AppModelsRoomType::where("status", "Active")->pluck("name", "id");
$data["lan_description"] = AppModelsRoomsDescriptionLang::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"] = AppModelsCountry::pluck("long_name", "short_name");
$data["amenities"] = AppModelsAmenities::active_all()->groupBy("type_id");
$data["users_list"] = AppModelsUser::pluck("first_name", "id");
$data["room_id"] = $request->id;
$data["result"] = AppModelsRooms::find($request->id);
// dd($data['result']);
$data["rooms_photos"] = AppModelsRoomsPhotos::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"] = AppModelsRooms::getLenghtOfStayOptions();
$data["availability_rules_months_options"] = AppModelsRooms::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

Related Posts

Codeigniter : Parse error: syntax error, unexpected ‘const’ (T_CONST), expecting variable (T_VARIABLE) in Laravel project

I’m getting following error: **Parse error: syntax error, unexpected ‘const’ (T_CONST), expecting variable (T_VARIABLE)** Note : It’s working in local but facing issue in production server. private…

Firebase receive notification while tab is active or on focus

What i want is to be able to perform an action when a user receives a notification while the browser is open and tab is active or…

Laravel’s alias loader does not find class

We have a legacy project that we cannot update and we need to make some changes in symfony’s Response.php in vendor. We have solved this by copying…

Laravel 5 – generic document management

I have a system where you can create different types of unique documents. For instance, one document is called Project Identified and this expects certain inputs. Originally,…

Laravel Nova limit the results in indexQuery

I ran intro a situation where I need to limit the results of a resource to only 3 results. To be more specific, based on the logged…

Auditoria en laravel 5.8 [closed]

Cómo puedo automatizar el registro de actividades de un usuario en laravel? Si un usuario ingresa a un app de laravel, debo guardar toda su actividas, a…

Leave a Reply

Your email address will not be published.