van1310

van1310

Associate Laravel Developer at Rigel Networks Vadodara

Member Since 2 Years Ago

bhavnagar

Experience Points
45,220
Total
Experience

4,780 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
151
Lessons
Completed
Best Reply Awards
21
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 10
45,220 XP
Oct
27
3 days ago
Activity icon

Replied to How To Enum Datatype Using Multiple Values Store?

@sinnbeck

^ array:1 [▼
	0 => array:12 [▼
	"email" => "[email protected]"
		"phone" => null
		"alert_level" => "client"
		"client_id" => "102"
		"salescenter_id" => null
 	"location_id" => null
		"alert_for" => "fraudalert,disposition"
		"added_by" => 348
		"added_for_client" => "102"
		"type" => "email"
		"created_at" => "2020-10-27 09:57:15"
	"updated_at" => "2020-10-27 09:57:15"
	]
]
Activity icon

Started a new Conversation How To Enum Datatype Using Multiple Values Store?

hii i have column like datatype is enum and also store multiple value like comma seperated so is it possible to store ?

here is my code i try but i cant find any solution

here is my migrations

public function up()
	{
    	Schema::table('fraud_alerts', function (Blueprint $table) {
        		$table->enum('alert_for',['disposition','fraudalert'])->after('type')->nullable()->comment('Alert For');
    });
	}

here is my controller code

 public function store(Request $request){
	$requestData = $request->all();
	foreach($requestData['email'] as $i => $list){
		$data = array();
		$all = ['fraudalert','disposition'];
		$rowdata = array();
		if(in_array("all",$requestData['email_alert_for'])){
                    	$rowdata['alert_for'] = implode(',' , $all);
                	 }else{
               		$rowdata['alert_for'] = $requestData['email_alert_for'];
                	 }
		array_push($data,$rowdata);
                	FraudAlert::insert($data);
	}
}

i try but everytime store null value in alert_for column

Oct
23
1 week ago
Activity icon

Replied to Default Multiselect Dropdown Checkbox Not Working

@jay_chauhan ok so i want client name when page refresh default select client name display but in my case not working so how can i get this client name

here is my ajax response

$.each(response.data.salescenters, function(key,value){
	var vid = value.id;
	var conNumToString = vid.toString().split("");
	if(response.data.selectedsalescenters){
   			var salesArray = '';
   			if(alertLevel == "salescenter"){
      			salesArray = response.data.selectedsalescenters.split(',');
   			}else if(alertLevel == "sclocation"){
     		salesArray = response.data.selectedsalescenters.split(',');
   		}
}
if(Array.isArray(salesArray) && salesArray.indexOf(conNumToString) !== 1){
  		console.log('1');
  		$("#edit-location-"+splitData[2]).append('<option value='+ value.id +'>'+ value.name +'</option>').prop('selectedIndex',salesArray).trigger('change');
}
else{
 		console.log('2');
 		$("#edit-location-"+splitData[2]).append('<option value='+ value.id +'>'+ value.name +'</option>').trigger('change');
}
$("#edit-location-"+splitData[2]).multiSelect('refresh'); // init the select
Activity icon

Replied to How To Get Auth::user()->id In JWT Api ?

@martin20 let try this

// the token is valid and we have find the user via the sub claim
$user = JWTAuth::parseToken()->authenticate();
$userId = $user->id;

hope its work for you

Activity icon

Replied to How To Get Auth::user()->id In JWT Api ?

@martin20

$user->user_create_id = \Auth::user()->id;
Oct
22
1 week ago
Activity icon

Started a new Conversation Select Option Css Change And Like Input Textbox

hii i have one select dropdown and i want css like this dropdown like textbox input field so how can i do it

here is my code

<div class="form-group sales-location-enabled">
	<select class="form-control location-select-class" name="locations[]" multiple="multiple" >
		<option value="{{$client->id}}">{{$client->name}}</option>
	</select>
</div>
Oct
21
1 week ago
Activity icon

Replied to How To Fetch Multiple Selected Checkbox In Dropdown Using Jquery

anyone suggestion for this issue ?

Activity icon

Started a new Conversation How To Fetch Multiple Selected Checkbox In Dropdown Using Jquery

dropdown edit time not fetch selected value checked in jquery dropdown always return last selected element how to fetch selected checked value in dropdown

here is my code

$(document).on('change','.edit-alert-select-class',function(){
	var eid = $(this).attr('id');
	var splitData = eid.split("-");	
	var fid = $("#fid-"+splitData[2]).val();
	var alertLevel = $( "#edit-level-"+splitData[2]+" option:selected" ).val();
	if(alertLevel != 'client')
	{
		$.ajax({
			type:'POST',
			data:{'_token':'{{csrf_token()}}','alertLevel': alertLevel,'clientId':'{{$client->id}}','fid': fid},
			url:"{{route('findclientsalescenter')}}",
			success:function(response){
				$("#edit-location-"+splitData[2]).empty();
				$.each(response.data.salescenters, function(key,value){
					var vid = value.id;
					var conNumToString = vid.toString().split("");
					if(response.data.selectedsalescenters){
						var salesArray = '';
						if(alertLevel == "salescenter"){
							salesArray = response.data.selectedsalescenters.split(',');
						}else if(alertLevel == "sclocation"){
							salesArray = response.data.selectedsalescenters.split(',');
						}
					}
					if(Array.isArray(salesArray) && salesArray.indexOf(conNumToString) !== 1){
						console.log('1');
						$("#edit-location-"+splitData[2]).append('<option value='+ value.id +'selected>'+ value.name +'</option>').trigger('change');
					}
					else{
						console.log('2');
						$("#edit-location-"+splitData[2]).append('<option value='+ value.id +'>'+ value.name +'</option>').trigger('change');
					}
					$("#edit-location-"+splitData[2]).multiSelect('refresh'); // init the select
				});
				// $("#edit-location-"+splitData[2]).multiSelect('refresh'); // init the select
			}
		});
	}
});
Oct
20
1 week ago
Activity icon

Started a new Conversation Default Multiselect Dropdown Checkbox Not Working

hii guys i have question like i have multiselect checkbox dropdown in value fetch using append but when i page refresh then default select "client Level" not working can you suggest how to do it?

here is my code

$("#emaillocation-"+splitData[1]).empty();
    $("#emaillocation-"+splitData[1]).append('<option value="{{$client->id}}"> {{$client->name}} </option>').attr("checked","checked").trigger('change');
    $("#emaillocation-"+splitData[1]).multiSelect('refresh');
Oct
16
2 weeks ago
Activity icon

Replied to How To Array To Update Multiple Rows

i do it my self resolved issue thank for support @silencebringer @sinnbeck

 elseif(!empty($requestData['edit_email']) && count($requestData['edit_email']) > 0){
            foreach($requestData['edit_email'] as $i => $list){                    
                $ids = array();
                $ids = $requestData['fid-'.($i+1)]; //current id
                $editrow['email']=$requestData['edit_email'][$i];
                $editrow['phone'] = NULL;
                switch($requestData['edit_email_alert_level'][$i]){
                    case 'client':
                        $editrow['alert_level'] = "client";
                        $editrow['client_id'] = (!empty($requestData['edit_locations-'.($i+1)])) ? implode("," ,$requestData['edit_locations-'.($i+1)]) : NULL;
                        $editrow['salescenter_id'] = NULL;
                        $editrow['location_id'] = NULL; 
                        break;
                    case 'salescenter':
                        $editrow['alert_level'] = "salescenter";
                        $editrow['client_id'] = NULL;
                        $editrow['salescenter_id'] = (!empty($requestData['edit_locations-'.($i+1)])) ? implode("," ,$requestData['edit_locations-'.($i+1)]) : NULL;
                        $editrow['location_id'] = NULL;
                        break;
                    case 'sclocation':
                        $editrow['alert_level'] = "sclocation";
                        $editrow['location_id'] = (!empty($requestData['edit_locations-'.($i+1)])) ? implode("," ,$requestData['edit_locations-'.($i+1)]) : NULL; 
                        $editrow['client_id'] = NULL;
                        $editrow['salescenter_id'] = NULL;                            
                        break;
                    default:
                        break;
                }
                FraudAlert::where('id',$ids)->update($editrow);
            }              
        }
Oct
15
2 weeks ago
Activity icon

Replied to How To Array To Update Multiple Rows

@sinnbeck @silencebringer

array:6 [▼
      "_token" => "sTUoBilbfwZfp0x6tSdZhB4S5YQTO7l0xlip0QzA"
     "clientId" => "102"
     "fid" => array:2 [▼
          0 => "228"
          1 => "231"
     ]
     "edit_email" => array:2 [▼
         0 => "[email protected]"
         1 => "[email protected]"
   ]
   "edit_email_alert_level" => array:2 [▼
      0 => "sclocation"
      1 => "client"
   ]
  "edit_locations" => array:2 [▼
     0 => "12"
     1 => "3"
  ]

]

this type of array i need to update for each id so how can i do it

Activity icon

Replied to How To Array To Update Multiple Rows

@sinnbeck i have field like email, alert_level, select

in which its alert_level fields like client/salescenter/location and select field like depend on alert_level

when i update all three fields then its not working like its multiple times

Activity icon

Replied to How To Array To Update Multiple Rows

@silencebringer @sinnbeck i use whereIn() but in case when i update data then old data save and new data also add so not remove old and replace new data

Activity icon

Replied to How To Array To Update Multiple Rows

@silencebringer so how can i do it can i remove $id?

Activity icon

Started a new Conversation How To Array To Update Multiple Rows

hii i m stuck in array through update my records i have array set in which i update multiple rows so how can i do it here is my code

if(!empty($requestData['edit_email']) && count($requestData['edit_email']) > 0){
            foreach($requestData['edit_email'] as $i => $list){
                $ids = array();
                $editdata = array();
                array_push($ids,$requestData['fid']);                    
                $editrow['email']=$requestData['edit_email'][$i];
                $editrow['phone'] = NULL;
                // dd($requestData['edit_email_alert_level']);
                switch($requestData['edit_email_alert_level'][$i]){
                    case "0":
                        $editrow['alert_level'] = "client";
                        $editrow['client_id'] = (!empty($requestData['edit_locations'])) ? implode("," ,$requestData['edit_locations']) : NULL;
                        $editrow['salescenter_id'] = NULL;
                        $editrow['location_id'] = NULL;
                        break;
                    case "1":
                        $editrow['alert_level'] = "salescenter";
                        $editrow['salescenter_id'] = (!empty($requestData['edit_locations'])) ? implode("," ,$requestData['edit_locations']) : NULL;
                        $editrow['client_id'] = NULL;
                        $editrow['location_id'] = NULL;
                        break;
                    case "2":
                        $editrow['alert_level'] = "sclocation";
                        $editrow['location_id'] = (!empty($requestData['edit_locations'])) ? implode("," ,$requestData['edit_locations']) : NULL;                            
                        $editrow['salescenter_id'] = NULL;
                        $editrow['client_id'] = NULL;
                        break;
                    default:
                        break;
                }                    
            } 
            array_push($editdata,$editrow);
            FraudAlert::where('id', $ids)->update($editdata);
            // dd($ids);
            // dd($requestData['fid']);               
        }

when i update record then error SQLSTATE[42S22]: Column not found: 1054 Unknown column '0' in 'field list' (SQL: update fraud_alerts set 0 = [email protected], updated_at = 2020-10-15 05:23:31 where id = 222)

Oct
14
2 weeks ago
Activity icon

Started a new Conversation Replace Select2 To Input Text Dynamic

hii i have dropdown like client/sales/location and anthor dropdown is dependent to previous one like when i select client then other dropdown fetch value to client level table when i select sales then fetch value to other dropdown in sales table

in case of when i select client then i have only one value so when i select client level then remove other dropdown and add input box to replace select2 dropdown how it possible?

here is my code

$(document).ready(function(){
	$('.location-select-class').multiSelect();
	$(document).on('change','.alert-select-class',function(){
		var eid = $(this).attr('id');
		var splitData = eid.split("-");
		let alertLevel = $(this).val();
		if(alertLevel != 'client')
		{
			$.ajax({
				type:'POST',
				data:{'_token':'{{csrf_token()}}','alertLevel': alertLevel,'clientId':'{{$client->id}}'},
				url:"{{route('findclientsalescenter')}}",
				success:function(response){
					$("#emaillocation-"+splitData[1]).empty();
					$.each(response.data, function(key,value){
						$("#emaillocation-"+splitData[1]).append('<option value='+ value.id +'>'+ value.name +'</option>').trigger('change');
						$("#emaillocation-"+splitData[1]).multiSelect('refresh'); 
					});
				}
			});
		}
		else
		{
			$("#emaillocation-"+splitData[1]).empty();
			$("#emaillocation-"+splitData[1]).append('<option value="{{$client->id}}"> {{$client->name}} </option>').prop("selected","selected").trigger('change');
			$("#emaillocation-"+splitData[1]).multiSelect('refresh'); 
		}
	});
});

i want input box in else condtion so replace select and add input in else condition how to do it

Oct
13
2 weeks ago
Activity icon

Replied to Remove Class In Not Working

@a4ashraf i try both the scenario but in this case remove first time perfect but second time i click to remove then all option will removed can you please suggest more example?

Activity icon

Replied to Remove Class In Not Working

@a4ashraf yes how to do it

i have code inside

<div class="col-xs-12 col-sm-12 col-md-12 removecloned-email" id="removed_email">
	//html
</div>

i remove whole div id remove email class

Activity icon

Replied to Remove Class In Not Working

@automica i try this but same result

Activity icon

Started a new Conversation Remove Class In Not Working

i have delete confirmation box in which i have lots of record but when i click to delete button then hide option then i page refresh remaning all option display again i click delete then hide all how to stop all option hide in modal

here is my code

$(document).on('click','.remove_field1-email',function(e){
	e.preventDefault();
	var eid = $(this).attr('id');
	var splitData = eid.split("-");
	var fid = $('#fid-'+splitData[2]).val();
	$('#confirm_delete').click(function(){
	if(fid){
		$.ajax({
			type:'POST',
			data:{'_token':'{{csrf_token()}}','fid': fid},
			url:"{{route('fraudalert.destroy')}}",
			success:function(response){
				if (response.status == 'success') {
					printAjaxSuccessMsg(response.message);	
				} else {
					printAjaxErrorMsg(response.message);
					}	
				$("#removed_email").closest('.edit-cloned-email').remove();	
				$('#delete-fraudalert-email').modal("hide");							
				}
			});
			}
		});	
	});
Oct
09
3 weeks ago
Activity icon

Started a new Conversation Dependent Dropdown Not Working On Edit Data

hello i have data like dependent dropdown when i click to 'alert_level' then fetch automatically location field data but in edit on data its does not work

supppose i have 2 field alert level and location when i click to alert level data then display location dropdown automatically in same edit time alert level data selected and also location dropdown data selected so how to do it

here is my code for add data ajax call this code is only add data so how can i check for edit mode

$(document).on('change','.alert-select-class',function(){
		var eid = $(this).attr('id');
		var splitData = eid.split("-");
		console.log(splitData);
		let alertLevel = $(this).val();
		if(alertLevel != 'client')
		{
			$.ajax({
				type:'POST',
				data:{'_token':'{{csrf_token()}}','alertLevel': alertLevel,'clientId':'{{$client->id}}'},
				url:"{{route('findclientsalescenter')}}",
				success:function(response){
					$("#location-"+splitData[1]).empty();
					$.each(response.data, function(key,value){
						$("#location-"+splitData[1]).append('<option value='+ value.id +'>'+ value.name +'</option>').trigger('change');
						$("#location-"+splitData[1]).multiSelect('refresh'); // init the select	for Email Single Dropdown
					});
				}
			});
		}
		else
		{
			$("#location-"+splitData[1]).empty();
			$("#location-"+splitData[1]).append('<option value="{{$client->id}}"> {{$client->name}} </option>').prop("selected","selected").trigger('change');
			$("#location-"+splitData[1]).multiSelect('refresh'); // init the select	for Email Single Dropdown
			//code to print client name suing {{$client->name}} in select dropdown
		}
	});
Activity icon

Awarded Best Reply on Array Store In Stuck

@a4ashraf thank you for your response

i found solution

public function store(Request $request)
{
    try
    {   
        $requestData = $request->all();
        $data = array();
        //Check Email is empty or not and also check count email is greater then zero
        if(!empty($requestData['email']) && count($requestData['email']) > 0){
            foreach($requestData['email'] as $i => $list){
                //Create seperate array for email
                $rowdata = array();
                $rowdata['email']=$requestData['email'][$i];
                $rowdata['phone'] = NULL;
                switch($requestData['email_alert_level'][$i]){
                    case 'client':
                    $rowdata['alert_level'] = "client";
                    $rowdata['client_id'] = (!empty($requestData['emaillocations-'.($i+1)])) ? implode("," ,$requestData['emaillocations-'.($i+1)]) : NULL;
                    $rowdata['salescenter_id'] = NULL;
                    $rowdata['location_id'] = NULL;
                    break;
                    case 'salescenter':
                        $rowdata['alert_level'] = "salescenter";
                        $rowdata['salescenter_id'] = (!empty($requestData['emaillocations-'.($i+1)])) ? implode("," ,$requestData['emaillocations-'.($i+1)]) : NULL;
                        $rowdata['client_id'] = NULL;
                    $rowdata['location_id'] = NULL;
                    break;
                    case 'sclocation':
                        $rowdata['alert_level'] = "sclocation";
                        $rowdata['location_id'] = (!empty($requestData['emaillocations-'.($i+1)])) ? implode("," ,$requestData['emaillocations-'.($i+1)]) : NULL;
                        $rowdata['salescenter_id'] = NULL;
                    $rowdata['client_id'] = NULL;
                    break;
                    default:
                    break;
                }
                $rowdata['added_by'] = Auth::Id();
                $rowdata['added_for_client'] = $requestData['clientId'];
                $rowdata['type'] = "email";
                $rowdata['created_at']= date('Y-m-d H:i:s');
                $rowdata['updated_at']= date('Y-m-d H:i:s');
                array_push($data,$rowdata);
            }
        }
        //Check sms is empty or not and also check count sms is greater then zero
        if(!empty($requestData['sms']) && count($requestData['sms']) > 0){
            foreach($requestData['sms'] as $i => $list){
                //Create seperate array for sms
                $rowdata = array();
                $rowdata['phone']=$requestData['sms'][$i];
                $rowdata['email']=NULL;
                switch($requestData['sms_alert_level'][$i]){
                    case 'client':
                    $rowdata['alert_level'] = "client";
                    $rowdata['client_id'] = (!empty($requestData['smslocations-'.($i+1)])) ? implode("," ,$requestData['smslocations-'.($i+1)]) : NULL;
                    $rowdata['salescenter_id'] = NULL;
                    $rowdata['location_id'] = NULL;
                    break;
                    case 'salescenter':
                        $rowdata['alert_level'] = "salescenter";
                        $rowdata['salescenter_id'] = (!empty($requestData['smslocations-'.($i+1)])) ? implode("," ,$requestData['smslocations-'.($i+1)]) : NULL;
                        $rowdata['location_id'] = NULL;
                    $rowdata['client_id'] = NULL;
                    break;
                    case 'sclocation':
                        $rowdata['alert_level'] = "sclocation";
                        $rowdata['location_id'] = (!empty($requestData['smslocations-'.($i+1)])) ? implode("," ,$requestData['smslocations-'.($i+1)]) : NULL;
                        $rowdata['salescenter_id'] = NULL;
                        $rowdata['client_id'] = NULL;
                    break;
                    default:
                    break;
                }
                $rowdata['added_by'] = Auth::Id();
                $rowdata['added_for_client'] = $requestData['clientId'];
                $rowdata['type'] = "phone";
                $rowdata['created_at']= date('Y-m-d H:i:s');
                $rowdata['updated_at']= date('Y-m-d H:i:s');
                array_push($data,$rowdata);
            }
        }
        FraudAlert::insert($data);
    }
    catch(\Exception $exception){
        return back()->with('error',$exception->getMessage());
    }
}
Activity icon

Replied to Array Store In Stuck

@a4ashraf thank you for your response

i found solution

public function store(Request $request)
{
    try
    {   
        $requestData = $request->all();
        $data = array();
        //Check Email is empty or not and also check count email is greater then zero
        if(!empty($requestData['email']) && count($requestData['email']) > 0){
            foreach($requestData['email'] as $i => $list){
                //Create seperate array for email
                $rowdata = array();
                $rowdata['email']=$requestData['email'][$i];
                $rowdata['phone'] = NULL;
                switch($requestData['email_alert_level'][$i]){
                    case 'client':
                    $rowdata['alert_level'] = "client";
                    $rowdata['client_id'] = (!empty($requestData['emaillocations-'.($i+1)])) ? implode("," ,$requestData['emaillocations-'.($i+1)]) : NULL;
                    $rowdata['salescenter_id'] = NULL;
                    $rowdata['location_id'] = NULL;
                    break;
                    case 'salescenter':
                        $rowdata['alert_level'] = "salescenter";
                        $rowdata['salescenter_id'] = (!empty($requestData['emaillocations-'.($i+1)])) ? implode("," ,$requestData['emaillocations-'.($i+1)]) : NULL;
                        $rowdata['client_id'] = NULL;
                    $rowdata['location_id'] = NULL;
                    break;
                    case 'sclocation':
                        $rowdata['alert_level'] = "sclocation";
                        $rowdata['location_id'] = (!empty($requestData['emaillocations-'.($i+1)])) ? implode("," ,$requestData['emaillocations-'.($i+1)]) : NULL;
                        $rowdata['salescenter_id'] = NULL;
                    $rowdata['client_id'] = NULL;
                    break;
                    default:
                    break;
                }
                $rowdata['added_by'] = Auth::Id();
                $rowdata['added_for_client'] = $requestData['clientId'];
                $rowdata['type'] = "email";
                $rowdata['created_at']= date('Y-m-d H:i:s');
                $rowdata['updated_at']= date('Y-m-d H:i:s');
                array_push($data,$rowdata);
            }
        }
        //Check sms is empty or not and also check count sms is greater then zero
        if(!empty($requestData['sms']) && count($requestData['sms']) > 0){
            foreach($requestData['sms'] as $i => $list){
                //Create seperate array for sms
                $rowdata = array();
                $rowdata['phone']=$requestData['sms'][$i];
                $rowdata['email']=NULL;
                switch($requestData['sms_alert_level'][$i]){
                    case 'client':
                    $rowdata['alert_level'] = "client";
                    $rowdata['client_id'] = (!empty($requestData['smslocations-'.($i+1)])) ? implode("," ,$requestData['smslocations-'.($i+1)]) : NULL;
                    $rowdata['salescenter_id'] = NULL;
                    $rowdata['location_id'] = NULL;
                    break;
                    case 'salescenter':
                        $rowdata['alert_level'] = "salescenter";
                        $rowdata['salescenter_id'] = (!empty($requestData['smslocations-'.($i+1)])) ? implode("," ,$requestData['smslocations-'.($i+1)]) : NULL;
                        $rowdata['location_id'] = NULL;
                    $rowdata['client_id'] = NULL;
                    break;
                    case 'sclocation':
                        $rowdata['alert_level'] = "sclocation";
                        $rowdata['location_id'] = (!empty($requestData['smslocations-'.($i+1)])) ? implode("," ,$requestData['smslocations-'.($i+1)]) : NULL;
                        $rowdata['salescenter_id'] = NULL;
                        $rowdata['client_id'] = NULL;
                    break;
                    default:
                    break;
                }
                $rowdata['added_by'] = Auth::Id();
                $rowdata['added_for_client'] = $requestData['clientId'];
                $rowdata['type'] = "phone";
                $rowdata['created_at']= date('Y-m-d H:i:s');
                $rowdata['updated_at']= date('Y-m-d H:i:s');
                array_push($data,$rowdata);
            }
        }
        FraudAlert::insert($data);
    }
    catch(\Exception $exception){
        return back()->with('error',$exception->getMessage());
    }
}
Oct
08
3 weeks ago
Activity icon

Replied to Array Store In Stuck

@a4ashraf

array:8 [▼
	"_token" => "e0uC4L4uMl8zBV785aY6gmY9kaTTdVWmChWy0tcJ"
	"clientId" => "102"
	"email" => array:1 [▼
		0 => "[email protected]"
	]
	"email_alert_level" => array:1 [▼
		0 => "salescenter"
	]
	"emaillocations-1" => array:2 [▼
		0 => "2022"
		1 => "2002"
	]
	"sms" => array:1 [▼
		0 => "1231231231"
	]
	"sms_alert_level" => array:1 [▼
		0 => "sclocation"
	]
	"smslocations-1" => array:2 [▼
		0 => "12"
		1 => "22"
	]
]
Activity icon

Replied to Array Store In Stuck

@a4ashraf thank you i try some code error Undefined variable: clientId

public function store(Request $request)
	{
   
    	$fraudAlert = new FraudAlert;
    	$json = $request->all();
    	$data = $json;

    	$finalData = array();
    	$blankArr = array();

        if(isset($data['clientId'])){
    	    array_push($blankArr,$data);
    	}else{
        		$blankArr = $data;
    	}

    	foreach($blankArr as $key => $value){
       		 $email = $value['email'];
        		$phone = $value['sms'];
        		$addedBy = "";
        		$addedByClient = $value['clientId'];
        		$locations = $value['email_alert_level'];
        		$locationsms = $value['sms_alert_level'];

        		foreach($value['email_alert_level'] as $k => $v){
            		if($email == "email"){
                			if($locations == "salescenter"){
                    			$salescenterId = $value['locations'][$k];
                    			$type = "email";
                			}
                			elseif($locations == "sclocation"){
                    			$locationId = $value['locations'][$k];
                    			$type = "email";
                			}
                			elseif($locations == "client"){
                    			$clientId = $value['locations'][$k];
                    			$type = "email";
                			}
            		}
            		$finalData = array(
                			'email' => $email,
                			'client_id' => implode(",",$clientId),
                			'salescenter_id' => implode(",",$salescenterId),
                			'location_id' => implode(",",$locationId),
               			 'added_by' => $addedBy,
               			 'added_for_client' => $addedByClient,
                			'type' => $type
            		);
           			 $store = $fraudAlert::insert($finalData);
        		}
        		foreach($value['sms_alert_level'] as $k => $v){
            		if($phone == "phone"){
                			if($locationsms == "salescenter"){
                    			$salescenterId = $value['locations'][$k];
                    			$type = "phone";
                			}
                			elseif($locationsms == "sclocation"){
                    			$locationId = $value['locations'][$k];
                    			$type = "phone";
                			}
                			elseif($locationsms == "client"){
                    			$clientId = $value['locations'][$k];
                    			$type = "phone";
                			}
            		}
            		$finalData = array(
                			'phone' => $phone,
                			'client_id' => implode(",",$clientId),
               			 'salescenter_id' => implode(",",$salescenterId),
               			 'location_id' => implode(",",$locationId),
               			 'added_by' => $addedBy,
             			 'added_for_client' => $addedByClient,
               			 'type' => $type
            		);
            		$store = $fraudAlert::insert($finalData);
        		}
    	}
	}
Activity icon

Started a new Conversation Array Store In Stuck

how to store in my database i have array like this

 array:8 [▼
	"_token" => "e0uC4L4uMl8zBV785aY6gmY9kaTTdVWmChWy0tcJ"
	"clientId" => "102"
	"email" => array:1 [▼
			0 => "[email protected]"
	]
	"email_alert_level" => array:1 [▼
			0 => "salescenter"
	]
	"emaillocations-1" => array:2 [▼
			0 => "2022"
			1 => "2002"
	]
	"sms" => array:1 [▼
			0 => "1231231231"
	]
	"sms_alert_level" => array:1 [▼
			0 => "sclocation"
	]
	"smslocations-1" => array:2 [▼
			0 => "12"
			1 => "22"
	]
]

i have this type of array and store in particlar field in store like sms array then store in sms field so how can i code for this please suggest me

Oct
07
3 weeks ago
Activity icon

Replied to Store Last Element Value Always Stuck

@rodrigo.pedra thank you sir you made my day lots of learn some new code techniques

Activity icon

Replied to Store Last Element Value Always Stuck

@a4ashraf no no sir

i have also append data i can store dynamic dropdown and store

i have also append script

$(document).ready(function() {
	var max_fields_limit = 100; //set limit for maximum input fields
	var x = 1; //initialize counter for text box

	$('.add_more_button').click(function(e){ //click event on add more fields button having class add_more_button
		e.preventDefault();
    	if(x < max_fields_limit){ //check conditions
			x++; //counter increment
			var data = '<div id="parent">' +
						'<div class="col-xs-12 col-sm-12 col-md-12">' +
							'<div class="col-md-4">' +
								'<div class="form-group">' +
									'<input type="text" class="form-control" name="email[]">' +
								'</div>' +
							'</div>' +
							'<div class="col-md-3">' +
								'<div class="form-group">' +
									'<select class="form-control1-select1" id="Alert_Level" name="email_alert_level[]">' +
										'<option value="client"> Client Level</option>' +
										'<option value="salescenter"> Sales Center Level</option>' +
										'<option value="sclocation"> Sales Center Location Level</option>' +
									'</select>' +
								'</div>' +
								'</div>' +
							'<div class="col-md-3">' +
								'<div class="form-group sales-append-location-enabled">' +
									'<select class="select2 form-control" name="email_location[]" id="Phone_Select" multiple="multiple">' +
									'</select>' +
								'</div>' +
							'</div>' +
						'<div class="col-md-2">' +
							'<div class="form-group">' +
								// '<button class="btn btn-success add_more_button1"> Add </button>' +
								'<button class="btn btn-danger remove_field"><i class="fa fa-remove"></i></button>' +
							'</div>' +
						'</div>' +
					'</div>' +
				'</div>';

				$('.input_fields_container').append(data); //add input field
				$(".select2").select2(); // init the select	
			}
	});
	$('.input_fields_container').on("click",".remove_field", function(e){ //user click on remove text links
    	e.preventDefault(); 
		$('#parent').remove(); x--;
	})

	var max_fields_limit1 = 100; //set limit for maximum input fields
	var x1 = 1; //initialize counter for text box

	$('.add_more_button1').click(function(e){ //click event on add more fields button having class add_more_button
	e.preventDefault();				
    if(x1 < max_fields_limit1){ //check conditions
        x1++; //counter increment
		var data1 = '<div id="parent1">' +
						'<div class="col-xs-12 col-sm-12 col-md-12">' +
							'<div class="col-md-4">' +
								'<div class="form-group">' +
									'<input type="text" class="form-control" name="phone[]">' +
								'</div>' +
							'</div>' +
							'<div class="col-md-3">' +
								'<div class="form-group">' +
									'<select class="form-control1-select1" id="SAlert_Level" name="sms_alert_level[]">' +
										'<option value="client"> Client Level</option>' +
										'<option value="salescenter"> Sales Center Level</option>' +
										'<option value="sclocation"> Sales Center Location Level</option>' +
									'</select>' +
								'</div>' +
							'</div>' +
						'<div class="col-md-3">' +
							'<div class="form-group sales-append-location-enabled">' +
								'<select class="select2 form-control" name="phone_location[]" id="SPhone_Select" multiple="multiple">' +
								'</select>' +
							'</div>' +
						'</div>' +
						'<div class="col-md-2">' +
							'<div class="form-group">' +
								// '<button class="btn btn-success add_more_button1"> Add </button>' +
								'<button class="btn btn-danger remove_field1"><i class="fa fa-remove"></i></button>' +
							'</div>' +
						'</div>' +
					'</div>' +
				'</div>';
        		$('.input_fields_container1').append(data1); //add input field
				$(".select2").select2(); // init the select
		}
	});
	$('.input_fields_container1').on("click",".remove_field1", function(e){ //user click on remove text links
    	e.preventDefault(); 
		$('#parent1').remove(); x1--;
	})
});
Activity icon

Replied to Store Last Element Value Always Stuck

@a4ashraf yes sure

here is my blade file

<form method="POST" action="{{route('admin.fruadalert.store')}}">
	{{csrf_field()}}
	<div class="input_fields_container">
		<div class="col-xs-12 col-sm-12 col-md-12">
			<div class="col-md-4">
				<div class="form-group">
					<label>Email</label>
					<input type="text" class="form-control" name="email[]">
				</div>
			</div>
			<div class="col-md-3">
				<div class="form-group">
					<label>Alert Level</label>
					<select class="form-control1-select1" name="email_alert_level[]" id="AlertLevel">
						<option value="client"> Client Level</option>
						<option value="salescenter"> Sales Center Level</option>
						<option value="sclocation"> Sales Center Location Level</option>
					</select>
				</div>
			</div>
			<div class="col-md-3">
				<div class="form-group sales-location-enabled">
					<label>Select</label>
					<select class="select2 form-control" name="email_location[]" id="PhoneSelect" multiple="multiple">
					</select>
				</div>
			</div>
			<div class="col-md-2">
				<div class="form-group">
					<button class="btn btn-success t-mar add_more_button"><i class="fa fa-plus"></i></button>
				</div>
			</div>
		</div>
	</div>
	<div class="input_fields_container1">
		<div class="col-xs-12 col-sm-12 col-md-12">
			<div class="col-md-4">
				<div class="form-group">
					<label>SMS</label>
					<input type="number" name="phone[]" class="form-control">
				</div>
			</div>
			<div class="col-md-3">
				<div class="form-group">
					<label>Alert Level</label>
					<select class="form-control1-select1" name="phone_alert_level[]" id="SAlertLevel">							
						<option value="client"> Client Level</option>
						<option value="salescenter"> Sales Center Level</option>
						<option value="sclocation"> Sales Center Location Level</option>
					</select>
				</div>
			</div>
			<div class="col-md-3">
				<div class="form-group sales-location-enabled">
					<label>Select</label>
					<select class="select2 form-control" name="phone_location[]" id="SPhoneSelect" multiple="multiple" >
					</select>
				</div>
			</div>
			<div class="col-md-2">
				<div class="form-group">
					<button class="btn btn-success t-mar add_more_button1"><i class="fa fa-plus"></i></button>
				</div>
			</div>
		</div>
	</div>
	<div class="col-xs-12 col-sm-12 col-md-12 text-center">
		<button type="submit" class="btn btn-success">Submit</button>
		<button type="reset" class="btn btn-danger">Cancel</button>
	</div>
</form>
Activity icon

Replied to Store Last Element Value Always Stuck

@rodrigo.pedra ok thank you sir

array:7 [▼
	"_token" => "J3Ae58gONAL6eaj2PL9dApbyD7NsBs8sDUCU9u6c"
	"email" => array:1 [▼
		0 => "[email protected]"
	]
	"email_alert_level" => array:1 [▼
		0 => "salescenter"
	]
	"email_location" => array:2 [▼
		0 => "0"
		1 => "1"
	]
	 "phone" => array:1 [▼
		0 => "1231231231"
	]
	"phone_alert_level" => array:1 [▼
		0 => "sclocation"
	]
	"phone_location" => array:2 [▼
		0 => "0"
		1 => "1"
	]
]
Activity icon

Replied to Store Last Element Value Always Stuck

@rodrigo.pedra implode(): Invalid arguments passed error fire and yes i used count

Activity icon

Started a new Conversation Store Last Element Value Always Stuck

hii i have array value then i store multiple entries then store everytime last element value i m stuck please help me

here is my controller code

$input = $request->all();
    	$fraudAlertData = new FraudAlert;
    	if(isset($input['email']) && !empty($input['email']))
	{
        		for($i=0; $i < count($input['email_alert_level']); ++$i )
		{
            		$fraudAlertData->email = $input['email'][$i];
            		$fraudAlertData->type = "email";
            		if($input['email_alert_level'] == "client"){
                			$fraudAlertData->alert_level = $input['email_alert_level'][$i];
            		}else if($input['email_alert_level'] == "salescenter"){
                			$fraudAlertData->alert_level = $input['email_alert_level'][$i];
               		 	$fraudAlertData->salescenter_id = implode(', ',$input['email_location'][$i]);
            		}else if($input['email_alert_level'] == "sclocation"){
                		$fraudAlertData->alert_level = $input['email_alert_level'][$i];
                		$fraudAlertData->location_id = implode(', ',$input['email_location'][$i]);
            		}
		}
    	}

	if(isset($input['phone']) && !empty($input['phone']))
	{
        		for($i=0; $i < count($input['phone_alert_level']); ++$i )
		{
            		$fraudAlertData->email = $input['phone'][$i];
            		$fraudAlertData->type = "phone";
            		if($input['phone_alert_level'] == "Client Level"){
                			$fraudAlertData->alert_level = "Client";
            		}else if($input['phone_alert_level'] == "Sales Center Level"){
                			$fraudAlertData->alert_level = "salescenter";
                			$fraudAlertData->salescenter_id = implode(', ',$input['phone_location'][$i]);
            		}else if($input['phone_alert_level'] == "Sales Center Location Level"){
                		$fraudAlertData->alert_level = "sclocation";
                		$fraudAlertData->location_id = implode(', ',$input['phone_location'][$i]);
            		}
        		}
    	}
    	$fraudAlertData->client_id = "102";
    	$fraudAlertData->added_by = '';
    	$fraudAlertData->save();

always phone number entry store condition dosent work please help me when i store email then data store only email or else phone number data store other field null how to do it

Sep
28
1 month ago
Activity icon

Replied to Pre Select Method Using Jquery Not Working

@silencebringer thank you

but not working becasue i have same method use in uper code for

so i have database value in agent-restrict-state like nj,mz,aj but pre select nj,mz,aj,tx,pa

so any problem in trigger or because i m working on same method in upper like

var state = response.data.sales_agent_details.state;
         	if (state != null && state != '') {
                	var states = state.split(',');
               	$('.multi-select-button').html(state);
                   		for (var i in states) {
                   			var optionVal = states[i];
                                	$("#agent-state").val(states);                                    
                                $("input[value=" + optionVal + "]").trigger('click');
                            }                                
           		}


	var restrict_state = response.data.sales_agent_details.restrict_state;
           		if (restrict_state != null && restrict_state != '') {
                            var restrict_state1 = restrict_state.split(',');
                            console.log(restrict_state1);
                            $('.restrict-multi-select-button').html(restrict_state);
                            for (var i in restrict_state1) {
                                var optionVal1 = restrict_state1[i];                                    
                                    $("#agent-restrict-state").val(restrict_state1);
                                 	$('input[value="' + optionVal1 + '"]').trigger('click');
                            }                                
               	}

any issue for uper method trggier issue or ?

in state field i have tx,pa and restrict state field i have nj,mz,aj

but in my case restrict state selected both value in dropdown now how can i resolved

Activity icon

Started a new Conversation Pre Select Method Using Jquery Not Working

i have already record on this record i update then i want pre select value on dropdown but its not working i use jquery and ajax so please suggest how to do it

var restrict_state = response.data.sales_agent_details.restrict_state;
    	if (restrict_state != null && restrict_state != '') {

           		var restrict_state1 = restrict_state.split(',');
                    	console.log(restrict_state1);
                            $('.restrict-multi-select-button').html(restrict_state);
                            for (var i in restrict_state1) {
                            	var optionVal1 = restrict_state1[i];
                                	console.log($("#agent-restrict-state").find("option[value=" + optionVal1 + "]"));       
                  $("#agent-restrict-state").find("option[value=" + optionVal1 + "]").prop("selected", "selected");
                       $('input[value="' + optionVal1 + '"]').trigger('click');
                            }
                            // $("#agent-restrict-state").multiSelect("refresh");
           	}

in my blade file

<select class="select2 form-control" id="agent-restrict-state" name="restrict_state[]" multiple="multiple" data-parsley-errors-container="#agent-restrict-state-error">
   		@foreach(getStates() as $state)                            
             	<option value="{{$state->state}}">{{$state->state}} </option>
        	@endforeach
 	</select>
Sep
25
1 month ago
Sep
24
1 month ago
Activity icon

Replied to Session Destroy After Redirect Other Route?

@sinnbeck sir can you please guide me am i right or wrong

protected function unauthenticated($request, AuthenticationException $exception)
	{

    	return ($request->expectsJson() || $request->isJson())
            	    ? response()->json(['message' => $exception->getMessage()], 401)
                	: redirect()->guest(route('inactivity'))->withErrors([
                	'failed' => "Please login to access this page"]);
	}

i just replace the route in expection/handler file so is thiis correct or not?

Activity icon

Started a new Conversation Session Destroy After Redirect Other Route?

my question is when my session is destroy then redirect not in login i want to redirect another route so how to set route and where is set the route in which file or controller please guys help me i dont know how to set

Activity icon

Replied to Swal Not Defined Laravel

@kikogyh

import swal from 'sweetalert2';

window.swal = swal

or

<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
Sep
08
1 month ago
Sep
07
1 month ago
Activity icon

Replied to How To Validate That End Date Is Greater Than Start Date

@lilo yes blade file inside in script tag

Activity icon

Replied to How To Validate That End Date Is Greater Than Start Date

@lilo

$(document).ready(function () {

    $("#dt1").datepicker({
        dateFormat: "dd-M-yy",
        minDate: 0,
        onSelect: function (date) {
            var dt2 = $('#dt2');
            var startDate = $(this).datepicker('getDate');
            var minDate = $(this).datepicker('getDate');
            dt2.datepicker('setDate', minDate);
            startDate.setDate(startDate.getDate() + 30);
            //sets dt2 maxDate to the last day of 30 days window
            dt2.datepicker('option', 'maxDate', startDate);
            dt2.datepicker('option', 'minDate', minDate);
            $(this).datepicker('option', 'minDate', minDate);
        }
    });
    $('#dt2').datepicker({
        dateFormat: "dd-M-yy"
    });
});
Aug
24
2 months ago
Activity icon

Started a new Conversation Upply Plugin Using Delete File From Database

hii i have question like i use uppy plugin for upload files but when i click on remove button only remove in preview but i also remove from database so how i can do it?

https://uppy.io/docs/

Aug
18
2 months ago
Activity icon

Replied to Group By Month And Company (SUM & COUNT)

@bhhussain its not impossible

here is example

SELECT SUM(job_invoice_amount)
FROM(SELECT COUNT( * ) AS job_invoice_amount
FROM companies);
Aug
05
2 months ago
Activity icon

Replied to What Is The Best Way To Export 1 Million Records

@martinbean @tinfoilman ok sir i understand but my client said in one click export whatever data into database sir so how can i understand to my client its not possible?

Activity icon

Replied to What Is The Best Way To Export 1 Million Records

@snapey @sinnbeck i need all of data old and new all data when i export