I have three table
-
hotel
-
hotel_feature
-
hotel_feature_assing
hotel and hotel_feature have many to many relation
In hotel_feature_assing I will save id of hotel and id of the feature.
In edit section I have check box, I want to show check box checked
if current hotel(editing one) have the feature. How can I check that the current hotel is already assigned to make checked my checkbox?
this is my Hotel Model:
public function features()
{
return $this->belongsToMany(HotelFeature::class, 'hotel_feature_assigns');
}
and in HotelFeature model:
public function hotel()
{
return $this->belongsToMany(Hotel::class);
}
this is my checkbox:
@foreach($hotelfeatures as $key => $hotelfeature)
<input type="checkbox" name="idhotelfeature[]" id="idhotelfeature" value=""
style="margin-right:5px" @if ($hotel->is_feature)
checked
@endif><span class="font-weight-normal"></span>
@endforeach
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire