Anonymous
Неверный аргумент указан для foreach() на странице просмотра, вызывающей проблему laravel5.5
Сообщение
Anonymous » 19 окт 2024, 07:03
При попытке обновить или получить данные на странице редактирования возникает следующая проблема. Неверный аргумент указан для foreach() в области Form::select().
Ниже приведен мой контроллер:< /p>
Код: Выделить всё
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(["", "", 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++;
}
И просмотреть файл следующим образом:
Код: Выделить всё
{!! Form::open(['url' => ADMIN_URL.'/edit_room/'.$room_id='', 'class' => 'form-horizontal', 'id' => 'add_room_form', 'files' => true]) !!}
{!! $calendar??'' !!}
(*)Fields are Mandatory
Rooms and Beds
Bedrooms
*
{!! Form::select('bedrooms', $bedrooms='', $result->bedrooms, ['class' => 'form-control', 'id' => 'bedrooms', 'placeholder' => 'Select...']) !!}
Beds
*
{!! Form::select('beds', $beds, $result->beds, ['class' => 'form-control', 'id' => 'beds', 'placeholder' => 'Select...']) !!}
Bed Type
*
{!! Form::select('bed_type', $bed_type, $result->bed_type, ['class' => 'form-control', 'id' => 'bed_type', 'placeholder' => 'Select...']) !!}
Я не понимаю, что в этом плохого. в dd($result) получение всех значений атрибутов, но не получение ehy, возникает эта ошибка.
В настоящее время я работаю над версией laravel5.5.
У кого-нибудь есть идеи, пожалуйста, дайте мне знать
Подробнее здесь:
https://stackoverflow.com/questions/690 ... laravel5-5
1729310604
Anonymous
При попытке обновить или получить данные на странице редактирования возникает следующая проблема. Неверный аргумент указан для foreach() в области Form::select(). Ниже приведен мой контроллер:< /p> [code]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(["", "", 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++; } [/code] И просмотреть файл следующим образом: [code]{!! Form::open(['url' => ADMIN_URL.'/edit_room/'.$room_id='', 'class' => 'form-horizontal', 'id' => 'add_room_form', 'files' => true]) !!} {!! $calendar??'' !!} (*)Fields are Mandatory Rooms and Beds Bedrooms * {!! Form::select('bedrooms', $bedrooms='', $result->bedrooms, ['class' => 'form-control', 'id' => 'bedrooms', 'placeholder' => 'Select...']) !!} Beds * {!! Form::select('beds', $beds, $result->beds, ['class' => 'form-control', 'id' => 'beds', 'placeholder' => 'Select...']) !!} Bed Type * {!! Form::select('bed_type', $bed_type, $result->bed_type, ['class' => 'form-control', 'id' => 'bed_type', 'placeholder' => 'Select...']) !!} [/code] Я не понимаю, что в этом плохого. в dd($result) получение всех значений атрибутов, но не получение ehy, возникает эта ошибка. В настоящее время я работаю над версией laravel5.5. У кого-нибудь есть идеи, пожалуйста, дайте мне знать Подробнее здесь: [url]https://stackoverflow.com/questions/69028618/invalid-argument-supplied-for-foreach-in-view-page-getting-issue-laravel5-5[/url]