Kanchan186

Kanchan186

Software Engineer at Pune

Member Since 7 Months Ago

Pune,Maharashtra

Experience Points
10,400
Total
Experience

4,600 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
10
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

Level 3
10,400 XP
Feb
04
1 month ago
Activity icon

Started a new Conversation How To Set Validation On Dynamic Dependent Dropdown

when i select industry dropdown then shows validation to segment dropdown

view

 <form class="m-t-40" method="post" action="{{url('/')}}/brand" enctype="multipart/form-data" novalidate>
                                    {{csrf_field()}}

                                    <div class="form-group">
                                    <h5>Industry Name <span class="text-danger">*</span></h5>
                                        
                                        <div class="controls">
                                            
                                             <select class="form-control" name="industry_id" onchange="getSegment(this.value)" required data-validation-required-message="This field is required">
                                            
                                            <option>--Select Industry--</option>
                                            @foreach($industry as $br)
                                            <option value="{{$br->industry_id}}">{{$br->industry_name}}</option>
                                            @endforeach
                                        </select>

                                        </div>
                                       
                                    </div>
                                    

                                    

                                    <div class="form-group">
                                        <h5>Segment Name <span class="text-danger">*</span></h5>
                                        <div class="controls">
                                            
                                             <select class="form-control" name="segment_id" id="segment_id" required data-validation-required-message="This field is required">
                                                <option>--Select Segment--</option>
                                           
                                        </select>

                                        </div>
                                       
                                    </div>

                                      <div class="form-group">
                                        <h5>Brand Name <span class="text-danger">*</span></h5>
                                        <div class="controls">
                                            <input type="text" name="brand_name" id ="brand_name" class="form-control" required data-validation-required-message="This field is required"> </div>
                                       
                                    </div>
                                     <div class="form-group">
                                        <h5>Brand Logo <span class="text-danger">*</span></h5>
                                        <div class="controls">
                                            <input type="file" name="brand_logo" id ="brand_logo" class="form-control" required data-validation-required-message="This field is required"> </div>
                                       
                                    </div>
                                    
                                            <div class="text-xs-right">
                                                <button type="submit" class="btn btn-info">Submit</button>
                                                <button type="reset" class="btn btn-inverse">Cancel</button>
                                            </div>
                                </form>

script

<script type="text/javascript">


  function getSegment(industry)
    {
       if(industry) {
                $.ajax({
                    url: '{{url('/')}}/segment/ajax/'+industry,
                    type: "GET",
                    dataType: "json",
                    success:function(data) {
                    console.log(data)
                        $('select[name="segment_id"]').empty();
                        $('select[name="segment_id"]').prepend('<option value="">--Select Segment--</option>');
                        $.each(data, function(key, value) {
                            $('select[name="segment_id"]').append('<option value="'+ key +'">'+ value +'</option>');
                        });

                    }
                });
            } else{
                 $('select[name="segment_id"]').empty();
            }
    }
   
</script>
Activity icon

Awarded Best Reply on When Unchecked The Only One Checkbox, It Removes All Checkboxes Output

updated code.

view


                <form class="m-t-40" method="post" action="{{url('/')}}/mechanic_brands/{{$mechanic->mechanic_id}}" enctype="multipart/form-data">
                                    {{csrf_field()}}

                                
                                      <div class="form-group">
                                        <h5>Segment<span class="text-danger">*</span></h5>
                                        <div class="controls">
                                            
                                @foreach($segment as $sg)
                                <ul><li>
                               <input type="checkbox" value="{{$sg->segment_id }}" name="sg[{{$sg->segment_id }}]" id="{{$sg->segment_id }}" onclick="getBrand1(this.id)" class="test">

                                <label  for="{{ $sg->segment_id }}">
                                <p>{{$sg->segment_name }}</p></label></li>
                                 <li id="{{$sg->segment_id +10000}}" ></li>

                            </ul>
                                
                                @endforeach
                                        </div>

                                       
                                    </div> 

                  
                      <div id="brands" >
                        <ul  style="list-style-type:none;display: flex;" class="ck-visible">
                        <li>
                         <input type="checkbox">   
                        </li> 
                        </ul>   

                      </div>  


                        </div>

                              
                                               
                        <div class="text-xs-right">
                        <button type="submit" class="btn btn-info">Submit</button>
                        <button type="reset" class="btn btn-inverse">Cancel</button>
                        </div>
                    </form>

script

<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
     <script type="text/javascript">

       function getBrand1(id)
   {
          //  alert('Choose brands!');

 if(document.getElementById(id).checked)  
   {  
       
       $.ajax({
        url: 'http://localhost/partsanalysis/public/brand/Ajax/'+id,
       type: "GET",
       dataType: "json",
        error: function(data, errorThrown)
          {
              console.log('request failed :'+errorThrown);
          },
       success:function(result) {
         console.log(result);
       // alert(result);


                $.each(result, function(index, value) { 

                // console.log(result, index, value);
                  var newvar=parseInt(id)+parseInt(10000);

 
                 var markup = "<ul  style='list-style-type:none;display: flex;margin: 0.2em; cursor: pointer; padding: 0.2em;'><li class='myip'><input  style='opacity:1;position:static;' type='checkbox' name='br[" + value.brand_id + "]' value='" + value.brand_id + "'></li><li>" + value.brand_name + "</li></ul>";
                        
                // $("#brands").append(markup);

                  $("#"+newvar).append(markup);
                 });

                   }
              });
          }     
      
        else
            {
                  var newvar=parseInt(id)+parseInt(10000);
                $('#'+newvar).html(""); 
            }
        

        }

</script>

it works..!

Activity icon

Replied to When Unchecked The Only One Checkbox, It Removes All Checkboxes Output

updated code.

view


                <form class="m-t-40" method="post" action="{{url('/')}}/mechanic_brands/{{$mechanic->mechanic_id}}" enctype="multipart/form-data">
                                    {{csrf_field()}}

                                
                                      <div class="form-group">
                                        <h5>Segment<span class="text-danger">*</span></h5>
                                        <div class="controls">
                                            
                                @foreach($segment as $sg)
                                <ul><li>
                               <input type="checkbox" value="{{$sg->segment_id }}" name="sg[{{$sg->segment_id }}]" id="{{$sg->segment_id }}" onclick="getBrand1(this.id)" class="test">

                                <label  for="{{ $sg->segment_id }}">
                                <p>{{$sg->segment_name }}</p></label></li>
                                 <li id="{{$sg->segment_id +10000}}" ></li>

                            </ul>
                                
                                @endforeach
                                        </div>

                                       
                                    </div> 

                  
                      <div id="brands" >
                        <ul  style="list-style-type:none;display: flex;" class="ck-visible">
                        <li>
                         <input type="checkbox">   
                        </li> 
                        </ul>   

                      </div>  


                        </div>

                              
                                               
                        <div class="text-xs-right">
                        <button type="submit" class="btn btn-info">Submit</button>
                        <button type="reset" class="btn btn-inverse">Cancel</button>
                        </div>
                    </form>

script

<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
     <script type="text/javascript">

       function getBrand1(id)
   {
          //  alert('Choose brands!');

 if(document.getElementById(id).checked)  
   {  
       
       $.ajax({
        url: 'http://localhost/partsanalysis/public/brand/Ajax/'+id,
       type: "GET",
       dataType: "json",
        error: function(data, errorThrown)
          {
              console.log('request failed :'+errorThrown);
          },
       success:function(result) {
         console.log(result);
       // alert(result);


                $.each(result, function(index, value) { 

                // console.log(result, index, value);
                  var newvar=parseInt(id)+parseInt(10000);

 
                 var markup = "<ul  style='list-style-type:none;display: flex;margin: 0.2em; cursor: pointer; padding: 0.2em;'><li class='myip'><input  style='opacity:1;position:static;' type='checkbox' name='br[" + value.brand_id + "]' value='" + value.brand_id + "'></li><li>" + value.brand_name + "</li></ul>";
                        
                // $("#brands").append(markup);

                  $("#"+newvar).append(markup);
                 });

                   }
              });
          }     
      
        else
            {
                  var newvar=parseInt(id)+parseInt(10000);
                $('#'+newvar).html(""); 
            }
        

        }

</script>

it works..!

Activity icon

Awarded Best Reply on How To Hide Data When Uncheck Checkbox

updated code

<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
     <script type="text/javascript">

       function getBrand1(id)
   {
          //  alert('Choose brands!');

 if(document.getElementById(id).checked)  
   {  
       
       $.ajax({
        url: 'http://localhost/partsanalysis/public/brand/Ajax/'+id,
       type: "GET",
       dataType: "json",
        error: function(data, errorThrown)
          {
              console.log('request failed :'+errorThrown);
          },
       success:function(result) {
         console.log(result);
       // alert(result);


                $.each(result, function(index, value) { 

                // console.log(result, index, value);
                  var newvar=parseInt(id)+parseInt(10000);

 
                 var markup = "<ul  style='list-style-type:none;display: flex;margin: 0.2em; cursor: pointer; padding: 0.2em;'><li class='myip'><input  style='opacity:1;position:static;' type='checkbox' name='br[" + value.brand_id + "]' value='" + value.brand_id + "'></li><li>" + value.brand_name + "</li></ul>";
                        
                // $("#brands").append(markup);

                  $("#"+newvar).append(markup);
                 });

                   }
              });
          }     
      
        else
            {
                  var newvar=parseInt(id)+parseInt(10000);
                $('#'+newvar).html(""); 
            }
        

        }

</script>

using this:

  else
            {
                  var newvar=parseInt(id)+parseInt(10000);
                $('#'+newvar).html(""); 
            }

getting proper output. it works

Activity icon

Replied to How To Hide Data When Uncheck Checkbox

updated code

<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
     <script type="text/javascript">

       function getBrand1(id)
   {
          //  alert('Choose brands!');

 if(document.getElementById(id).checked)  
   {  
       
       $.ajax({
        url: 'http://localhost/partsanalysis/public/brand/Ajax/'+id,
       type: "GET",
       dataType: "json",
        error: function(data, errorThrown)
          {
              console.log('request failed :'+errorThrown);
          },
       success:function(result) {
         console.log(result);
       // alert(result);


                $.each(result, function(index, value) { 

                // console.log(result, index, value);
                  var newvar=parseInt(id)+parseInt(10000);

 
                 var markup = "<ul  style='list-style-type:none;display: flex;margin: 0.2em; cursor: pointer; padding: 0.2em;'><li class='myip'><input  style='opacity:1;position:static;' type='checkbox' name='br[" + value.brand_id + "]' value='" + value.brand_id + "'></li><li>" + value.brand_name + "</li></ul>";
                        
                // $("#brands").append(markup);

                  $("#"+newvar).append(markup);
                 });

                   }
              });
          }     
      
        else
            {
                  var newvar=parseInt(id)+parseInt(10000);
                $('#'+newvar).html(""); 
            }
        

        }

</script>

using this:

  else
            {
                  var newvar=parseInt(id)+parseInt(10000);
                $('#'+newvar).html(""); 
            }

getting proper output. it works

Activity icon

Replied to How To Hide Data When Uncheck Checkbox

sorry sir but i am not getting this code .

Activity icon

Replied to How To Hide Data When Uncheck Checkbox

@sinnbeck i updated my code still it not work

<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
     <script type="text/javascript">

       function getBrand1(id)
   {
          //  alert('Choose brands!');

 if(document.getElementById(id).checked)  
   {  
       
       $.ajax({
        url: 'http://localhost/partsanalysis/public/brand/Ajax/'+id,
       type: "GET",
       dataType: "json",
        error: function(data, errorThrown)
          {
              console.log('request failed :'+errorThrown);
          },
       success:function(result) {
         console.log(result);
       // alert(result);


                $.each(result, function(index, value) { 

                // console.log(result, index, value);
                  var newvar=parseInt(id)+parseInt(10000);

 
                 var markup = "<ul  style='list-style-type:none;display: flex;margin: 0.2em; cursor: pointer; padding: 0.2em;'><li class='myip'><input  style='opacity:1;position:static;' type='checkbox' name='br[" + value.brand_id + "]' value='" + value.brand_id + "'></li><li>" + value.brand_name + "</li></ul>";
                        
                // $("#brands").append(markup);

                  $("#"+newvar).append(markup);
                 });

                   }
              });
          }     
      
        else
            {
                //$("#brands").html(""); 
                //$("#"+newvar).html("");  

             function myFunction() {
                 var x = document.getElementById("brands");
                if (x.style.display === "none") {
                 x.style.display = "block";
                 } else {
                 x.style.display = "none";
             }
           }  


            }
        

        }

</script>
Feb
03
1 month ago
Activity icon

Replied to How To Hide Data When Uncheck Checkbox

sir its user requirement to use checkbox

Feb
02
1 month ago
Activity icon

Started a new Conversation How To Hide Data When Uncheck Checkbox

when uncheck 2wheeler still it shows brands

view

 <form class="m-t-40" method="post" action="{{url('/')}}/mechanic_brands/{{$mechanic->mechanic_id}}" enctype="multipart/form-data">
                                    {{csrf_field()}}

                                
                                      <div class="form-group">
                                        <h5>Segment<span class="text-danger">*</span></h5>
                                        <div class="controls">
                                            
                                @foreach($segment as $sg)
                                <ul><li>
                               <input type="checkbox" value="{{$sg->segment_id }}" name="sg[{{$sg->segment_id }}]" id="{{$sg->segment_id }}" onclick="getBrand1(this.id)" class="test">

                                <label  for="{{ $sg->segment_id }}">
                                <p>{{$sg->segment_name }}</p></label></li>
                                 <li id="{{$sg->segment_id +10000}}" ></li>

                            </ul>
                                
                                @endforeach
                                        </div>

                                       
                                    </div> 

                  
                      <div id="brands" >
                        <ul  style="list-style-type:none;display: flex;" class="ck-visible">
                        <li>
                         <input type="checkbox">   
                        </li> 
                        </ul>   

                      </div>  


                        </div>

                              
                                               
                        <div class="text-xs-right">
                        <button type="submit" class="btn btn-info">Submit</button>
                        <button type="reset" class="btn btn-inverse">Cancel</button>
                        </div>
                    </form>

script

<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
     <script type="text/javascript">

       function getBrand1(id)
   {
          //  alert('Choose brands!');

 if(document.getElementById(id).checked)  
   {  
       
       $.ajax({
        url: 'http://localhost/partsanalysis/public/brand/Ajax/'+id,
       type: "GET",
       dataType: "json",
        error: function(data, errorThrown)
          {
              console.log('request failed :'+errorThrown);
          },
       success:function(result) {
         console.log(result);
       // alert(result);


                $.each(result, function(index, value) { 

                // console.log(result, index, value);
                  var newvar=parseInt(id)+parseInt(10000);

 
                 var markup = "<ul  style='list-style-type:none;display: flex;margin: 0.2em; cursor: pointer; padding: 0.2em;'><li class='myip'><input  style='opacity:1;position:static;' type='checkbox' name='br[" + value.brand_id + "]' value='" + value.brand_id + "'></li><li>" + value.brand_name + "</li></ul>";
                        
                // $("#brands").append(markup);

                  $("#"+newvar).append(markup);
                 });

                   }
              });
          }     
      
        else
            {
                $("#brands").html(" "); 
            }
        

        }

</script>

Jan
31
1 month ago
Activity icon

Started a new Conversation When Unchecked The Only One Checkbox, It Removes All Checkboxes Output

table: brands

table: Mech_brands

in this table stored segments with brands to mechanic_id

table: Mechanics

on this mechanics stored segments with proper brands.

so all data stored properly. but the problem is :

  1. when check segment 2wheeler or 4wheeler there brands are displayed combined so user may get confused which brands is for which segment.
  2. when uncheck segment 2wheeler it vanish all brands, there is no need to remove 4wheeler brands . when uncheck segment 4wheeler it vanish all brands, there is no need to remove 2 wheeler brands.

KTM,TVS and Suzuki is a two wheeler brands, Bajaj is four wheeler brand

my code

 <div class="row">
                    <div class="col-12">
                        <div class="card">
                            <div class="card-body">
                                <h4 class="card-title">Add Mechanic Brands</h4>
                                <h6 class="card-subtitle"></h6>
                                @if ($errors->any())
                                <div class="alert alert-danger">
                                    <ul>
                                        @foreach ($errors->all() as $error)
                                            <li>{{ $error }}</li>
                                        @endforeach
                                    </ul>
                                </div>
                            @endif

            <form class="m-t-40" method="post" action="{{url('/')}}/mechanic_brands/{{$mechanic->mechanic_id}}" enctype="multipart/form-data" novalidate>
                                    {{csrf_field()}}                                
                
                <div class="form-group">
                    <h5>Segment<span class="text-danger">*</span></h5>
                    <div class="controls">                                            
                    @foreach($segment as $sg)
                        <ul type="none">
                            <li>
                               <input type="checkbox" value="{{$sg->segment_id }}" name="sg[{{$sg->segment_id }}]" id="{{$sg->segment_id }}" onclick="getBrand1(this.id)">

                                <label  for="{{ $sg->segment_id }}">
                                    <p>{{$sg->segment_name }}</p>
                                </label>
                            </li>
                        </ul>                                
                                @endforeach
                        </div>

                                       
                    </div> 

                                        <div id="brands">
                                         
                                   
                                        </div>



                              
                                               
                                            <div class="text-xs-right">
                                                <button type="submit" class="btn btn-info">Submit</button>
                                                <button type="reset" class="btn btn-inverse">Cancel</button>
                                            </div>
                                </form>


                                </div>
                                </div>
                            </div>
                        </div>

script

<script type="text/javascript">

       function getBrand1(id)
   {
          //  alert('Choose brands!');

 if(document.getElementById(id).checked)  
   {  
       
       $.ajax({
        url: 'http://localhost/partsanalysis/public/brand/Ajax/'+id,
       type: "GET",
       dataType: "json",
        error: function(data, errorThrown)
          {
              console.log('request failed :'+errorThrown);
          },
       success:function(result) {
         console.log(result);
       // alert(result);


                $.each(result, function(index, value) { 

                 console.log(result, index, value);
 
                 var markup = "<ul type='none'><li><input type='checkbox' name='br[" + value.brand_id + "]' value='" + value.brand_id + "'></li><li>" + value.brand_name + "</li></ul>";
                        
                 $("#brands").append(markup);
                 });

                   }
              });
          }     
      
        else
            {
                $("#brands").html(""); 
            }  

        }

</script>

i want output like this:

when i check 2Wheeler then displays its brands below 2 wheeler segment and for 4 wheeler also same.

Jan
30
1 month ago
Activity icon

Replied to What Should I Do To Display Checkbox Values Below The Related Checked Values, Is There Need To Write Separate JS Code

@bobbybouwmann

i update my question

table: brands

table: Mech_brands

in this table stored segments with brands to mechanic_id

table: Mechanics

on this mechanics stored segments with proper brands.

so all data stored properly. but the problem is :

  1. when check segment 2wheeler or 4wheeler there brands are displayed combined so user may get confused which brands is for which segment.
  2. when uncheck segment 2wheeler it vanish all brands, there is no need to remove 4wheeler brands . when uncheck segment 4wheeler it vanish all brands, there is no need to remove 2 wheeler brands.

so, when i check 2Wheeler then displays its brands below 2 wheeler segment and for 4 wheeler also same.

Jan
29
2 months ago
Activity icon

Started a new Conversation What Should I Do To Display Checkbox Values Below The Related Checked Values, Is There Need To Write Separate JS Code

KTM,TVS and Suzuki is a two wheeler brands, Bajaj is four wheeler brand

my code

 <div class="row">
                    <div class="col-12">
                        <div class="card">
                            <div class="card-body">
                                <h4 class="card-title">Add Mechanic Brands</h4>
                                <h6 class="card-subtitle"></h6>
                                @if ($errors->any())
                                <div class="alert alert-danger">
                                    <ul>
                                        @foreach ($errors->all() as $error)
                                            <li>{{ $error }}</li>
                                        @endforeach
                                    </ul>
                                </div>
                            @endif

            <form class="m-t-40" method="post" action="{{url('/')}}/mechanic_brands/{{$mechanic->mechanic_id}}" enctype="multipart/form-data" novalidate>
                                    {{csrf_field()}}                                
                
                <div class="form-group">
                    <h5>Segment<span class="text-danger">*</span></h5>
                    <div class="controls">                                            
                    @foreach($segment as $sg)
                        <ul type="none">
                            <li>
                               <input type="checkbox" value="{{$sg->segment_id }}" name="sg[{{$sg->segment_id }}]" id="{{$sg->segment_id }}" onclick="getBrand1(this.id)">

                                <label  for="{{ $sg->segment_id }}">
                                    <p>{{$sg->segment_name }}</p>
                                </label>
                            </li>
                        </ul>                                
                                @endforeach
                        </div>

                                       
                    </div> 

                                        <div id="brands">
                                         
                                   
                                        </div>



                              
                                               
                                            <div class="text-xs-right">
                                                <button type="submit" class="btn btn-info">Submit</button>
                                                <button type="reset" class="btn btn-inverse">Cancel</button>
                                            </div>
                                </form>


                                </div>
                                </div>
                            </div>
                        </div>

script

<script type="text/javascript">

       function getBrand1(id)
   {
          //  alert('Choose brands!');

 if(document.getElementById(id).checked)  
   {  
       
       $.ajax({
        url: 'http://localhost/partsanalysis/public/brand/Ajax/'+id,
       type: "GET",
       dataType: "json",
        error: function(data, errorThrown)
          {
              console.log('request failed :'+errorThrown);
          },
       success:function(result) {
         console.log(result);
       // alert(result);


                $.each(result, function(index, value) { 

                 console.log(result, index, value);
 
                 var markup = "<ul type='none'><li><input type='checkbox' name='br[" + value.brand_id + "]' value='" + value.brand_id + "'></li><li>" + value.brand_name + "</li></ul>";
                        
                 $("#brands").append(markup);
                 });

                   }
              });
          }     
      
        else
            {
                $("#brands").html(""); 
            }  

        }

</script>
Jan
10
2 months ago
Activity icon

Started a new Conversation General Error: 1005 Can't Create Table `demosql`.`posts` (errno: 150 "Foreign Key Constraint Is Incorrectly Formed") (SQL: Alter Table `posts` Add Constraint `posts_emp_id_foreign` Foreign Key (`emp_id`) References `employees` (`emp_id`) On Delete Cascade

posts table

<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreatePostsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('posts', function (Blueprint $table) {
            $table->bigIncrements('post_id');
            $table->string('comment');
            $table->timestamps();
        });


         Schema::table('posts', function (Blueprint $table) {
            $table->integer('emp_id')->unsigned();
            $table->foreign('emp_id')->references('emp_id')->on('employees')->onDelete('cascade')->change();
           
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
         Schema::dropIfExists('posts');

        Schema::table('posts', function (Blueprint $table) {
          
            $table->dropForeign('posts_emp_id_foreign');
        });
    }
}

Dec
31
2 months ago
Activity icon

Replied to When Main Record Is Deleted How To Delete Its Related Record But " No Permanent Deletion" Changes Its Active_status=0 Only.

@tray2

i already used that and my data also deleted properly but it's a permanent Deletion. but i don't want permant deletion i just want set active_status value from 1 to 0

Activity icon

Started a new Conversation When Main Record Is Deleted How To Delete Its Related Record But " No Permanent Deletion" Changes Its Active_status=0 Only.

delete link:

<a href="{{url('/')}}/mechanic/{{$br->mechanic_id}}" onclick="return confirm('Do you want delete this record')"><i class="fas fa-trash" ></i>

web.php

//delete Mechanic
Route::get('mechanic/{mechanic_id}','[email protected]');

MechanicController


     public function destroy(Mechanic $mechanic_id)
    {

       // $mechanic = Mechanic::findOrFail($mechanic_id);

        //$mechanic_id::where('mechanics.mechanic_id',$mechanic_id->mechanic_id)
                  // ->where('mechanic_banks.mechanic_bank_id',$mechanic_id->mechanic_bank_id)
                
                  // ->where('mech_brands.mech_brand_id',$mechanic_id->mech_brand_id)
                
            // $mechanic_id->delete();
                   
         $mechanic_id->update([
                     
                      'active_status' => 0,
                
                     ]);

        return redirect('mechanic/view');
    }

mechanics table

mechanics table records

mechanic_banks table

mech_brands table

Activity icon

Replied to SQLSTATE[42S22]: Column Not Found: 1054 Unknown Column 'mechanic_banks.mechanic_bank_id' In 'where Clause' (SQL: Update `mechanics` Set `active_status` = 0, `status` = 0, `updated_at` = 2019-12-31 18:50:16 Where `mechanics`.`mechanic_id` = 9 And `mechanic

@siangboon sir i saw this video using below code

 public function destroy(Mechanic $mechanic_id)
    {
            $mechanic_id->delete();
          
            return redirect('mechanic/view');
      }

properly delete main record with related records also.

but i don't want permanent deletion, i just want to set active_status=0

by using this code:



     public function destroy(Mechanic $mechanic_id)
    {
            $mechanic_id->update([
                     
                      'active_status' => 0,
                    //  'status'=> 0,
                     ]);

        return redirect('mechanic/view');
    }

it changes only mechanics table active_status=0 but related record active_status=1.

i want to change mechanic_bank, mech_brands, and Mechanic_service_station active_status =0 when deleting the mechanic info.

Activity icon

Started a new Conversation SQLSTATE[42S22]: Column Not Found: 1054 Unknown Column 'mechanic_banks.mechanic_bank_id' In 'where Clause' (SQL: Update `mechanics` Set `active_status` = 0, `status` = 0, `updated_at` = 2019-12-31 18:50:16 Where `mechanics`.`mechanic_id` = 9 And `mechanic

link:

 <td><a href="{{url('/')}}/mechanic/{{$br->mechanic_id}}/edit"><i class="fas fa-edit"></i></a> 
  &nbsp;
<a href="{{url('/')}}/mechanic/{{$br->mechanic_id}}" onclick="return confirm('Do you want delete this record')"><i class="fas fa-trash" ></i>
 </td>

web.php

//delete Mechanic
Route::get('mechanic/{mechanic_id}','[email protected]');

MechanicController

 public function destroy(Mechanic $mechanic_id)
    {
        $mechanic_id::where('mechanics.mechanic_id',$mechanic_id->mechanic_id)
                   ->where('mechanic_banks.mechanic_bank_id',$mechanic_id->mechanic_bank_id)
                   ->where(' mechanic_service_station_infos.service_station_info_id',$mechanic_id->service_station_info_id)
                   ->where('mech_brands.mech_brand_id',$mechanic_id->mech_brand_id)
                    
            ->update([
                     
                      'active_status' => 0,
                      'status'=> 0,
                     ]);
        return redirect('mechanic/view');
    }
Activity icon

Replied to Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException No Message

@snapey please help me! how to do this , when deletion of main record its related record also delete means how to change related record active_status=0 with main record

Dec
30
2 months ago
Activity icon

Replied to Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException No Message

@snapey

now i updated my code please tell me what should i do now

delete link

<a href="{{url('/')}}/mechanic/{{$br->mechanic_id}}" onclick="return confirm('Do you want delete this record')"><i class="fas fa-trash" ></i>

web.php

//delete Mechanic
Route::get('mechanic/{mechanic}','[email protected]');

MechanicController


     public function destroy(Mechanic $mechanic)
    {
        $mechanic::where('mechanics.mechanic_id',$mechanic->mechanic_id)
                       
            ->update([
                     
                      'active_status' => 0,
                     ]);
        return redirect('mechanic/view');
    }

but this code changes only mechanic_id status to '0' after deletion

Activity icon

Replied to Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException No Message

@snapey i already set mechanic_id as a foreign key in all related tables but the problem is i don't want permanent deletion. i just want to it changes status from 1 to 0.

Activity icon

Started a new Conversation Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException No Message

how to delete related records in database

e.g if i delete mechanic personal info then how to delete its service_station, brands and bank info at same time.

please check my code where i going wrong

delete link

<a href="{{url('/')}}/mechanic/{{$br->mechanic_id}}/{{br->mech_brand_id}}/{{br->service_station_info_id}}/{{br->mechanic_bank_id}}" onclick="return confirm('Do you want delete this record')"><i class="fas fa-trash" ></i>

web.php


//delete Mechanic
Route::get('mechanic/{mechanic}/{mechanic_service_station_info}/{mechanic_bank}/{mech_brand}','[email protected]');

MechanicController.php

public function destroy(Mechanic $mechanic,MechanicServiceStationInfo $mechanic_service_station_info,MechanicBank $mechanic_bank,MechBrand $mech_brand)
    {
        $mechanic::where('mechanics.mechanic_id',$mechanic->mechanic_id)
                 ->where('mechanic_service_station_infos.service_station_info_id',$mechanic_service_station_info->service_station_info_id)
                 ->where('mechanic_banks.mechanic_bank_id',$mechanic_bank->mechanic_bank_id)
                 ->where('mech_brands.mech_brand_id',$mech_brand->mech_brand_id)

            ->update([
                     
                      'active_status' => 0,
                     ]);
        return redirect('mechanic/view');
    }
Activity icon

Started a new Conversation Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException No Message

please check where i going wrong

edit link

 <a href="{{url('/')}}/segment/{{$br->segment_id}}/edit"><i class="fas fa-edit"></i></a>  

web.php

//edit segment
Route::get('segment/{segment}/edit','[email protected]');
Route::patch('segment/{segment}','[email protected]');

editsegment.blade.php

<form class="m-t-40" method="post" action="{{url('/')}}/segment/{{$segment->segment_id}}" novalidate>
                                    {{csrf_field()}}
                                    

                                    
                                    <div class="form-group">
                                    <h5>Industry Name <span class="text-danger">*</span></h5>
                                    <div class="controls">
                                    
                                    <select name="industry_id" class="form-control" required data-validation-required-message="This field is required">
                                            
                                           @foreach($industry as $br)
                                            
                                                @if($br->industry_id == $segment->industry_id )
                                                     <option value="{{$br->industry_id}}" selected >{{$br->industry_name}}</option>
                                                @else
                                                     <option value="{{$br->industry_id}}">{{$br->industry_name}}</option>
                                                @endif

                                            @endforeach
                                                    </select>
                                                </div>
                                            </div>




                                      <div class="form-group">
                                        <h5>Segment Name <span class="text-danger">*</span></h5>
                                        <div class="controls">
                                            <input type="text" name="segment_name" id ="segment_name" class="form-control"  value="{{ $segment->segment_name}}" required data-validation-required-message="This field is required"> </div>
                                       
                                    </div>

                                    


                                    
                                            <div class="text-xs-right">
                                                <button type="submit" class="btn btn-info">Submit</button>
                                                <button type="reset" class="btn btn-inverse">Cancel</button>
                                            </div>
                                </form>

segmentController.php

public function edit(Segment $segment)
    {
        //dd($segment);

        $industry=Industry::where('industries.active_status', '=', 1)->get();
        //dd($industry);
        return view('backend.segment.editSegment',compact('segment','industry'));
    }

    public function update(Request $request,Segment $segment)
    {
        dd(request()->all());
        
        $segment->update($request->all());
 
        return redirect('segment/view');

    }
Dec
23
3 months ago
Activity icon

Replied to How To Set "required "validation For Multiple Dependent Dynamic Drop-down(values Comes From Database) List In Javascript

@van-india sir

there is dynamic dependent drop down and values comes from database please suggest me this type of solution

Activity icon

Started a new Conversation How To Set "required "validation For Multiple Dependent Dynamic Drop-down(values Comes From Database) List In Javascript

view


<div class="form-group">
            <h5>Select Country <span class="text-danger">*</span></h5>
            <div class="controls">
                                            
                <select class="form-control" name="emp_country" id="emp_country" onchange="getState(this.value)" required>
                <option>--Select country--</option>
                @foreach($country as $br)
                <option value="{{$br->country_id}}">{{$br->country_name}}</option>
                 @endforeach
                </select>
            </div>
        </div>
                
        <div class="form-group">
            <h5>Select State <span class="text-danger">*</span></h5>
            <div class="controls">
                                            
                <select class="form-control" name="emp_state" id="emp_state" onchange="getCity(this.value) " required>
                <option>--Select State--</option>
                     
                </select>
            </div>
        </div>

       <div class="form-group">
            <h5>Select City <span class="text-danger">*</span></h5>
            <div class="controls">

               <select class="form-control" name="emp_city" id="emp_city" required>
               <option>--Select City--</option>
               
               </select>
           </div>
     </div>

script

 <script type="text/javascript">
                        
                         function getState(country)
                            {
                               if(country) {
                                        $.ajax({
                                            url: '{{url('/')}}/state/ajax/'+country,
                                            type: "GET",
                                            dataType: "json",
                                            success:function(data) {

                                             // alert(data);
                                             console.log(data)
                                        
                                                $('select[name="emp_state"]').empty();
                                                $('select[name="emp_state"]').prepend('<option value="">--Select State--</option>');
                                                $.each(data, function(key, value) {
                                                    $('select[name="emp_state"]').append('<option value="'+ key +'">'+ value +'</option>');
                                                });

                                            }
                                        });
                                    } else{
                                         $('select[name="emp_city"]').empty();
                                    }
                            }
                        
                         function getCity(state)
                            {
                               if(state) {
                                        $.ajax({
                                            url: '{{url('/')}}/city/ajax/'+state,
                                            type: "GET",
                                            dataType: "json",
                                            success:function(data) {
                                                  console.log(data)

                                                $('select[name="emp_city"]').empty();
                                                $('select[name="emp_city"]').prepend('<option value="">--Select City--</option>');
                                                $.each(data, function(key, value) {
                                                    $('select[name="emp_city"]').append('<option value="'+ key +'">'+ value +'</option>');
                                                });

                                            }
                                        });
                                    } else{
                                         $('select[name="emp_city"]').empty();
                                    }
                            }
</script>

Activity icon

Replied to Checkbox Are Not Displayed (shows Only Value)

@snapey which type of css required to display checkboxes properly

Dec
20
3 months ago
Activity icon

Replied to Checkbox Are Not Displayed (shows Only Value)

@snapey

this CSS is used for checkbox in style.css

[type=checkbox]:checked, [type=checkbox]:not(:checked) {
    position: absolute;
    left: -9999px;
    opacity: 0;
}

when i delete left and opacity , it display like this

Activity icon

Replied to Checkbox Are Not Displayed (shows Only Value)

@snapey how to set CSS in javascript code

Activity icon

Started a new Conversation How To Set Validation To Dynamic Drop Down In Laravel

code:

addEmp view

                <div class="form-group">
                                        <h5>Employee alternate mobile <span class="text-danger">*</span></h5>
                                        <div class="controls">
                                            <input type="text" name="emp_alt_mobile" id ="emp_alt_mobile" class="form-control" required data-validation-containsnumber-regex="(\d)+" data-validation-containsnumber-message="No Characters Allowed, Only Numbers" maxlength="10"> </div>
                                       
                                    </div>
 <div class="form-group">
            <h5>Select Country <span class="text-danger">*</span></h5>
            <div class="controls">
                                            
                <select class="form-control" name="emp_country" id="emp_country" onchange="getState(this.value)" required>
                <option>--Select country--</option>
                @foreach($country as $br)
                <option value="{{$br->country_id}}">{{$br->country_name}}</option>
                 @endforeach
                </select>
            </div>
        </div>
                
        <div class="form-group">
            <h5>Select State <span class="text-danger">*</span></h5>
            <div class="controls">
                                            
                <select class="form-control" name="emp_state" id="emp_state" onchange="getCity(this.value) " required>
                <option>--Select State--</option>
                 @foreach($state as $st)
                <option value="{{$st->state_id}}">{{$st->state_name}}</option>
                @endforeach       
                </select>
            </div>
        </div>

       <div class="form-group">
            <h5>Select City <span class="text-danger">*</span></h5>
            <div class="controls">

               <select class="form-control" name="emp_city" id="emp_city" required>
               <option>--Select City--</option>
               
               </select>
           </div>
     </div>

                        <div class="form-group">
                                        <h5>Employee Address <span class="text-danger">*</span></h5>
                                        <div class="controls">
                                            <input type="text" name="emp_address" id ="emp_address" class="form-control" required data-validation-required-message="This field is required"> </div>
                                       
                                    </div>

script

  <script type="text/javascript">
                        
                         function getState(country)
                            {
                               if(country) {
                                        $.ajax({
                                            url: '{{url('/')}}/state/ajax/'+country,
                                            type: "GET",
                                            dataType: "json",
                                            success:function(data) {

                                             // alert(data);
                                             console.log(data)
                                        
                                                $('select[name="emp_state"]').empty();
                                                $('select[name="emp_state"]').prepend('<option value="">--Select State--</option>');
                                                $.each(data, function(key, value) {
                                                    $('select[name="emp_state"]').append('<option value="'+ key +'">'+ value +'</option>');
                                                });

                                            }
                                        });
                                    } else{
                                         $('select[name="emp_city"]').empty();
                                    }
                            }
                        
                         function getCity(state)
                            {
                               if(state) {
                                        $.ajax({
                                            url: '{{url('/')}}/city/ajax/'+state,
                                            type: "GET",
                                            dataType: "json",
                                            success:function(data) {
                                                  console.log(data)

                                                $('select[name="emp_city"]').empty();
                                                $('select[name="emp_city"]').prepend('<option value="">--Select City--</option>');
                                                $.each(data, function(key, value) {
                                                    $('select[name="emp_city"]').append('<option value="'+ key +'">'+ value +'</option>');
                                                });

                                            }
                                        });
                                    } else{
                                         $('select[name="emp_city"]').empty();
                                    }
                            }
</script>

EmployeeController


<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Department;
use App\Designation;
use App\Employee;
use App\City;
use App\Country;
use App\State;
use File;

class EmployeeController extends Controller
{
     public function __construct()
    {
        $this->middleware('auth');
    }
    public function Add()
    {

        $department=Department::where('departments.active_status', '=', 1)->get();
        $designation=Designation::where('designations.active_status', '=', 1)->get();
        $employee=Employee::get();
        $country=Country::where('country_name','India')->first();
        $state=State::where('country_id',$country->country_id)->get();
        $city = City::all();
        $country=Country::get();

        return view('backend.employee.addEmp',compact('department','employee','designation','state','city','country'));

    }

     public function cityAjax($state)
    {
        
        $city=City::where("state_id",$state)
                    ->pluck('cities.city_name','cities.city_id')->all();

        return json_encode($city);


    }

}
Dec
17
3 months ago
Activity icon

Started a new Conversation Checkbox Are Not Displayed (shows Only Value)

when i unchecked left alignment and opacity default checkboxes shows

please suggest me which inline CSS i need to add in code

view

 <form class="m-t-40" method="post" action="{{url('/')}}/mechanic_brands/{{$mechanic->mechanic_id}}" enctype="multipart/form-data" novalidate>
                                    {{csrf_field()}}

                                
                                      <div class="form-group">
                                        <h5>Segment<span class="text-danger">*</span></h5>
                                        <div class="controls">
                                            
                                @foreach($segment as $sg)
                                <ul><li>
                               <input type="checkbox" value="{{$sg->segment_id }}" name="sg[{{$sg->segment_id }}]" id="{{$sg->segment_id }}" onclick="getBrand1(this.id)" class="test" >

                                <label  for="{{ $sg->segment_id }}">
                                <p>{{$sg->segment_name }}</p></label></li></ul>
                                
                                @endforeach
                                        </div>

                                       
                                    </div> 

                                    <div id="brands" >
                                        <ul>
                                        <li>
                                        <input type="checkbox" >
                                        </li>   
                                       </ul>  
                                   
                                     </div>

                              
                                               
                                            <div class="text-xs-right">
                                                <button type="submit" class="btn btn-info">Submit</button>
                                                <button type="reset" class="btn btn-inverse">Cancel</button>
                                            </div>
                                </form>

script

<script type="text/javascript">

       function getBrand1(id)
   {
          //  alert('Choose brands!');

 if(document.getElementById(id).checked)  
   {  
       
       $.ajax({
        url: 'http://localhost/partsanalysis/public/brand/Ajax/'+id,
       type: "GET",
       dataType: "json",
        error: function(data, errorThrown)
          {
              console.log('request failed :'+errorThrown);
          },
       success:function(result) {
         console.log(result);
       // alert(result);


                $.each(result, function(index, value) { 

                 console.log(result, index, value);
 
                 var markup = "<ul><li><input type='checkbox' name='br[" + value.brand_id + "]' value='" + value.brand_id + "'></li><li>" + value.brand_name + "</li></ul>";
                        
                 $("#brands").append(markup);
                 });

                   }
              });
          }     
      
        else
            {
                $("#brands").html(""); 
            }
        

        }

</script>
Activity icon

Replied to SQLSTATE[23000]: Integrity Constraint Violation: 1452 Cannot Add Or Update A Child Row: A Foreign Key Constraint Fails (`db_partsanalysis`.`empzone_mappings`, CONSTRAINT `empzone_mappings_emp_id_foreign` FOREIGN KEY (`emp_id`) REFERENCES `employees` (`emp

 function getEmployee(designation)
                            {
                               if(designation) {
                                        $.ajax({
                                            url: '{{url('/')}}/employee/ajax/'+designation,
                                            type: "GET",
                                            dataType: "json",
                                            success:function(data) {
                                         console.log(data)
                                                $('select[name="emp_id"]').empty();
                                                $('select[name="emp_id"]').prepend('<option value="">--Select Employee--</option>');
                                                
                                                $.each(data, function(key, value) {
                                                    $('select[name="emp_id"]').append('<option value="'+ key +'">'+ value +'</option>');
                                                });

                                            }
                                        });
                                    } else{
                                         $('select[name="emp_id"]').empty();
                                    }
                            } 
Activity icon

Replied to SQLSTATE[23000]: Integrity Constraint Violation: 1452 Cannot Add Or Update A Child Row: A Foreign Key Constraint Fails (`db_partsanalysis`.`empzone_mappings`, CONSTRAINT `empzone_mappings_emp_id_foreign` FOREIGN KEY (`emp_id`) REFERENCES `employees` (`emp

now output shows like that

{4: "Manager"}4: "Manager"__proto__: Object

employee_zone_mapping:954 
(2) [{…}, {…}]
0: {emp_fname: "kanchan", emp_lname: "nawkar", emp_id: 18}
1: {emp_fname: "Riya", emp_lname: "Patil", emp_id: 23}
length: 2__proto__: Array(0)
Activity icon

Replied to SQLSTATE[23000]: Integrity Constraint Violation: 1452 Cannot Add Or Update A Child Row: A Foreign Key Constraint Fails (`db_partsanalysis`.`empzone_mappings`, CONSTRAINT `empzone_mappings_emp_id_foreign` FOREIGN KEY (`emp_id`) REFERENCES `employees` (`emp

employees table

and i updated code gives this output

public function employeeAjax($designation)
    {
        $employee = Employee::where('employees.active_status', '=', 1)
                    ->where("designation_id",$designation)
                    ->pluck('employees.emp_fname','employees.emp_id')->all();
        return json_encode($employee);
    }

but in add view it takes only employee first name but i want both first name and last name

Activity icon

Replied to SQLSTATE[23000]: Integrity Constraint Violation: 1452 Cannot Add Or Update A Child Row: A Foreign Key Constraint Fails (`db_partsanalysis`.`empzone_mappings`, CONSTRAINT `empzone_mappings_emp_id_foreign` FOREIGN KEY (`emp_id`) REFERENCES `employees` (`emp

@tykus

array:5 [▼
  "_token" => "tnjiyNbRqsOd5Kaf5BCP9NhqMXuBFVv8ZDp6dpBV"
  "department_id" => "1"
  "designation_id" => "4"
  "emp_id" => "0"
  "zo" => array:1 [▶]
]

it takes emp_id=0 due to this may be error occurs

Activity icon

Started a new Conversation SQLSTATE[23000]: Integrity Constraint Violation: 1452 Cannot Add Or Update A Child Row: A Foreign Key Constraint Fails (`db_partsanalysis`.`empzone_mappings`, CONSTRAINT `empzone_mappings_emp_id_foreign` FOREIGN KEY (`emp_id`) REFERENCES `employees` (`emp

controller

 public function employeeAjax($designation)
    {
        $employee = Employee::where('employees.active_status', '=', 1)
                    ->where("designation_id",$designation)
                    ->select('employees.emp_fname','employees.emp_lname','employees.emp_id')->get();
        return json_encode($employee);
    }

view

 <div class="form-group">
                                        <h5>Select Department <span class="text-danger">*</span></h5>
                                        <div class="controls">
                                            
                                             <select class="form-control" name="department_id" onchange="getDesignation(this.value)" required>
                                                <option>--Select Department--</option>
                                            @foreach($department as $br)
                                            <option value="{{$br->department_id}}">{{$br->department_name}}</option>
                                            @endforeach
                                        </select>

                                        </div>
                                       
                                    </div>

                                    <div class="form-group">
                                        <h5>Select Designation <span class="text-danger">*</span></h5>
                                        <div class="controls">
                                            
                                             <select class="form-control " name="designation_id"onchange="getEmployee(this.value)" required="" >
                                                <option>--Select Designation--</option>
                                         
                                        </select>
                                        </div>
                                       
                                    </div>

                                    <div class="form-group">
                                        <h5>Employee Name <span class="text-danger">*</span></h5>
                                        <div class="controls">
                                            
                                             <select class="form-control" name="emp_id" required>
                                                <option>--Select Employee--</option>
                                            @foreach($employee as $br)
                                            <option value="{{$br->emp_id}}">{{$br->emp_fname}}{{$br->emp_lname}}</option>
                                            @endforeach
                                        </select>

                                        </div>
                                       
                                    </div>

script

  function getEmployee(designation)
                            {
                               if(designation) {
                                        $.ajax({
                                            url: '{{url('/')}}/employee/ajax/'+designation,
                                            type: "GET",
                                            dataType: "json",
                                            success:function(data) {
                                         console.log(data)
                                                $('select[name="emp_id"]').empty();
                                                $('select[name="emp_id"]').prepend('<option value="">--Select Employee--</option>');
                                                $.each(data, function(key, value) {
                                                    $('select[name="emp_id"]').append('<option value="'+ key +'">'+ value +'</option>');
                                                });

                                            }
                                        });
                                    } else{
                                         $('select[name="emp_id"]').empty();
                                    }
                            } 
Dec
16
3 months ago
Activity icon

Replied to SQLSTATE[22007]: Invalid Datetime Format: 1366 Incorrect Integer Value: 'nawkar' For Column `db_partsanalysis`.`empzone_mappings`.`emp_id` At Row 1 (SQL: Insert Into `empzone_mappings` (`emp_id`, `department_id`, `designation_id`, `active_status`, `zone_i

@sinnbeck

when i used this code it takes emp_id= nawkar but it's wrong

 public function employeeAjax($designation)
    {
        $employee = Employee::where('employees.active_status', '=', 1)
                    ->where("designation_id",$designation)
                    ->pluck('employees.emp_fname','employees.emp_lname','employees.emp_id')->all();
        return json_encode($employee);
    }
Activity icon

Replied to SQLSTATE[22007]: Invalid Datetime Format: 1366 Incorrect Integer Value: 'nawkar' For Column `db_partsanalysis`.`empzone_mappings`.`emp_id` At Row 1 (SQL: Insert Into `empzone_mappings` (`emp_id`, `department_id`, `designation_id`, `active_status`, `zone_i

now the problem is, in add view in employee dynamic drop down shows only employee firstname, but i want both first name as well as last name

by using this code above output comes

     public function employeeAjax($designation)
    {
        $employee = Employee::where('employees.active_status', '=', 1)
                    ->where("designation_id",$designation)
                    ->pluck('employees.emp_fname','employees.emp_id')->all();
        return json_encode($employee);
    }
Activity icon

Replied to SQLSTATE[22007]: Invalid Datetime Format: 1366 Incorrect Integer Value: 'nawkar' For Column `db_partsanalysis`.`empzone_mappings`.`emp_id` At Row 1 (SQL: Insert Into `empzone_mappings` (`emp_id`, `department_id`, `designation_id`, `active_status`, `zone_i

@sinnbeck

now it takes proper id

array:5 [▼
  "_token" => "sDbyJC52Jw6ty0qVyoDnnEk5sWRpxMeuvi4zHzDn"
  "department_id" => "1"
  "designation_id" => "4"
  "emp_id" => "18"
  "zo" => array:1 [▶]
]

first it takes nawkar in for id value so it shows error