Şimdi mustafa abi sormadan neden böyle kullandığımı açıklayayım foreach gibi gelmiyor abi yapı o yüzden foreach'e sokamıyorum tek tek bu şekilde yapmak zorunda kaldım 😃
Şimdi asıl soru şu form-groups-container burada ki container sayısına ihtiyacım var çünkü card içinde ki ilk 2 input olabilir son 2 input olmayabilir input ekle dediğim zaman 3. den başlaması gerekir ama 1. den başlıyor
@if(isset($card) && $card->link_one_name && $card->link_one)
<div id="form-groups-container">
<div class="form-group row">
<label for="title" class="control-label col-lg-2 col-sm-4">1.Başlık<sup>*</sup></label>
<div class="col-lg-10 col-sm-8">
<input placeholder=" "id="title" type="text" name="link_1_name" class="form-control" value="{{$card->link_one_name}}">
</div>
</div>
<div class="form-group row">
<label for="title" class="control-label col-lg-2 col-sm-4">1.Link<sup>*</sup></label>
<div class="col-lg-10 col-sm-8" >
<input placeholder=""id="title" type="text" name="link_1" class="form-control" value="{{$card->link_one}}">
</div>
</div>
</div>
@endif
@if(isset($card) && $card->link_two_name && $card->link_two)
<div id="form-groups-container">
<div class="form-group row">
<label for="title" class="control-label col-lg-2 col-sm-4">2.Başlık<sup>*</sup></label>
<div class="col-lg-10 col-sm-8">
<input placeholder=" "id="title" type="text" name="link_2_name" class="form-control" value="{{$card->link_two_name}}">
</div>
</div>
<div class="form-group row">
<label for="title" class="control-label col-lg-2 col-sm-4">2.Link<sup>*</sup></label>
<div class="col-lg-10 col-sm-8" >
<input placeholder=""id="title" type="text" name="link_2" class="form-control" value="{{$card->link_two}}">
</div>
</div>
</div>
@endif
@if(isset($card) && $card->link_three_name && $card->link_three)
<div id="form-groups-container">
<div class="form-group row">
<label for="title" class="control-label col-lg-2 col-sm-4">3.Başlık<sup>*</sup></label>
<div class="col-lg-10 col-sm-8">
<input placeholder=" "id="title" type="text" name="link_3_name" class="form-control" value="{{$card->link_three_name}}">
</div>
</div>
<div class="form-group row">
<label for="title" class="control-label col-lg-2 col-sm-4">3.Link<sup>*</sup></label>
<div class="col-lg-10 col-sm-8" >
<input placeholder=""id="title" type="text" name="link_3" class="form-control" value="{{$card->link_three}}">
</div>
</div>
</div>
@endif
@if(isset($card) && $card->link_four_name && $card->link_four)
<div id="form-groups-container">
<div class="form-group row">
<label for="title" class="control-label col-lg-2 col-sm-4">4.Başlık<sup>*</sup></label>
<div class="col-lg-10 col-sm-8">
<input placeholder=" "id="title" type="text" name="link_4_name" class="form-control" value="{{$card->link_four_name}}">
</div>
</div>
<div class="form-group row">
<label for="title" class="control-label col-lg-2 col-sm-4">4.Link<sup>*</sup></label>
<div class="col-lg-10 col-sm-8" >
<input placeholder=""id="title" type="text" name="link_4" class="form-control" value="{{$card->link_four}}">
</div>
</div>
</div>
@endif
<div id="form-groups-container">
<div class="form-group row">
</div>
</div>
<div class="form-group row">
<div class="col-lg-offset-2 col-sm-offset-4 col-lg-10 col-sm-8">
<button type="button" id="add-form-group" class="btn btn-default">Ekle</button>
</div>
</div>
{!! Former::close() !!}
</div>
@push('after-scripts')
<link rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.9/dist/css/bootstrap-select.min.css">
<script src="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.9/dist/js/bootstrap-select.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css">
<script src="https://cdn.jsdelivr.net/npm/flatpickr"></script>
<script src="https://npmcdn.com/flatpickr/dist/l10n/tr.js"></script>
<script src="/backend/js/ckeditor.js"></script>
<script src='https://cdn.rawgit.com/kensnyder/quill-image-resize-module/3411c9a7/image-resize.min.js'></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<script>
$(document).ready(function() {
let count = document.querySelectorAll('.form-group-container').length + 1;
console.log(count);
if(count<=4)
{
$("#add-form-group").click(function() {
let newFormGroup = `
<div class="form-group row">
<label for="title${count}" class="control-label col-lg-2 col-sm-4">${count}.Başlık<sup>*</sup></label>
<div class="col-lg-10 col-sm-8">
<input placeholder="Başlık" id="link_${count}_name" type="text" name="link_${count}_name" class="form-control">
</div>
</div>
<div class="form-group row">
<label for="link${count}" class="control-label col-lg-2 col-sm-4">${count}.Link<sup>*</sup></label>
<div class="col-lg-10 col-sm-8">
<input placeholder="Link" id="link_${count}" type="text" name="link_${count}" class="form-control">
</div>
</div>
`;
$("#form-groups-container").append(newFormGroup);
count++;
});
}
else{
return;
}
});
</script>