jagdishabhiandroid

jagdishabhiandroid

PHP Developer at Mohali

Member Since 1 Year Ago

Manali,Himachal Pradesh ,India

Experience Points
1,340
Total
Experience

3,660 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
4
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start-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-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-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist 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 1
1,340 XP
Dec
11
10 months ago
Activity icon

Started a new Conversation Laravel Session Cleared On AJAX CALL

I have created some cart data in the session having key cart data when I hit any post ajax route the data of the session reset automatically. where is wrong in this here the controller where I check for user phone no for checking login status but when I hit this with ajax the session data clear automatically

my controller code is `public function check(Request $request) { //dd(Session::all());

    $validator = Validator::make($request->all(), [
                'phone' => 'required|numeric|',
    ]);
    if ($validator->fails()) {
        // return redirect()->back()->with('errors',$validator->errors())->withInput($request->only('phone', 'remember'));
        return response()->json(['success' => false, 'error' => $validator->errors()], 403);
    } else {

        $string = strlen('+91' . $request->phone);

        if ($string < 13) {

            return response()->json(['success' => 'invalid', 'message' => 'Please Enter a Valid Phone Number'], 401);
        }

        //dd($request->phone);

        $data = DB::table('users')->where('phone', $request->phone)->get();

        if ($data->count() <= 0) {


            return response()->json(array('success' => true, 'message' => 1, 'phone' => $request->phone));
        } else {
            return response()->json(array('success' => false, 'message' => 'The phone has already been taken.Please Login', 'phone' => $request->phone), 403);
        }
    }
}`

and my ajax call is : `axios.post(process.env.MIX_BASEURL+'/checkphone',

                    vm.checkphone,

                    )
                    .then(response => {

                        console.log(response)                                                 
                    if(response.status==200){
                        //alert('no can register');
                        if(response.data.message==1){
                            let phone_no=response.data.phone;
                            //sendotp(phone_no);
                            $("#phone1").addClass("is-valid");
                            showRegisterFormnext(phone_no);
                        }
                    }

                    })
                    .catch(error => {

                       var errors = error.response
                        console.log(error.response)
                        ///IF EMPTY FIELDS FOUND///
                        if (errors.status == 403) {
                            //alert('somthing went wrong')
                            if (errors.data.message) {
                               vm.errorsPhone = true
                               $("#phone1").addClass("is-invalid");
                                vm.PhoneError = errors.data.message
                             toastr["error"](errors.data.message);

                //                  swal({
                //     title: "Oops!",
                //     text: "no alredy exist please login",
                //     icon: "error",
                //     button: "ok"
                // });
                                  showLoginForm();   
                            }else{
                               if (errors.data.error.phone) {
                                    vm.errorsPhone = true
                                     $("#phone1").addClass("is-invalid");
                                    vm.PhoneError = _.isArray(errors.data.error.phone) ? errors.data.error.phone[0] : errors.data.error.phone
                                    toastr["error"](vm.PhoneError);
                                    //alert(vm.PhoneError)
                                }

                            }

                        }
                        if (errors.status == 401) {

                              toastr["error"](errors.data.message);
                            }

                    });
        }`
Nov
14
11 months ago
Activity icon

Started a new Conversation How Can Remove Whole Object On Empty Product_attribute Title?

here is my code :

` public function productdescription1(Request $request) {

    // if($request->header('User-Agent')=='okhttp/3.8.0'){
    //       return '';
    //     }
    // validator for product id 

    $validator = Validator::make($request->all(), [
                'product_id' => 'required|numeric',
    ]);


    //if product_id is null 
    if ($validator->fails()) {
        return response()->json(['error' => $validator->errors()], 403)->header('status', 403);
    } else {


        ///GET REQUESTED PRODUCT ID DATA
        $products = DB::table('products')->where('id', $request->product_id)->where('product_visibility', 1)->get();


        ///// check if product has some value
        if ($products->count() > 0) {

            foreach ($products as $product) {

                /////GETTING KEY HIGHLIGHS VALUE
                $productkeyhighlights = DB::table('product_keyhighlights')->where('product_id', $product->id)->get();
                ///check if there is data in product keyhighlights
                if ($productkeyhighlights->count() > 0) {
                    foreach ($productkeyhighlights as $keyhighlights) {
                        $highlight[] = array("id" => $keyhighlights->id, "highlight_value" => $keyhighlights->highlight_value);
                    }
                } else {
                    $highlight = array();
                }
                //dd($keyhighlights);
                ///GETTING PRODUCT SPECIFICATION VALUES
                $productspecification = DB::table('products_specifications')->where('product_id', $product->id)->get();
                ///check if there is data in product specifications
                if ($productspecification->count() > 0) {
                    foreach ($productspecification as $specification) {
                        $productsspecification[] = array("id" => $specification->id, "specification_title" => $specification->extra_title, "specification_value" => $specification->extra_value);
                    }
                } else {
                    $productsspecification = array();
                }


                ///GETTING PRODUCT FEATURES LIST
                $productfeatures = DB::table('product_features')->where('product_id', $product->id)->get();
                ///check if there is data in product features
                if ($productfeatures->count() > 0) {
                    foreach ($productfeatures as $features) {
                        $productsfeatures[] = array("id" => $features->id, "feature_title" => $features->feature_title, "feature_description" => $features->feature_description, "feature_image" => asset($features->feature_image));
                    }
                } else {
                    $productsfeatures = array();
                }


                ////PRODUCT OPTIONAL IMAGES
                $productphotos = DB::table('products_photos')->where('product_id', $product->id)->get();
                ///check if there is data in product features
                if ($productphotos->count() > 0) {
                    foreach ($productphotos as $photos) {
                        $productsphotos[] = array("id" => $photos->id, "image" => asset($photos->image));
                    }
                } else {
                    $productsphotos = array();
                }

                //   /////PRODUCT ATTRIBUTE


                $allattributes = DB::table('product_attributes')->where('subcategory_id', $product->subcat_id)->get(['attribute_title']);

                $valuesnew = DB::table('current_product_attribute_values')->where('product_id', $product->id)->get();

//dd($valuesnew);

                    $emptybool=false;
                // checking for empty attributes 

                if ($valuesnew->count() > 0) {

//echo 'am here';

                    // first foreach for 3 value 
                    foreach ($allattributes as $name) {

                        //echo $name->attribute_title;

                        $boo = false;


                        //   40 record loop 

                        $records = array();
                        foreach ($valuesnew as $compare) {


                            //   if attibute title are same
                            if ($compare->attribute_title == $name->attribute_title) {

                                if ($boo == false) {

                                    $titledata = $name->attribute_title;

                                    $holddata['title'] = $titledata;
                                    

                                    $boo = true;
                                }

                                $records[] = array("attribute_name" => $compare->attribute_value, "mpr" => $compare->attribute_mrp);
                            }
                            
                        }

                      
                        $holddata['records'] = $records;
                        $final[] = $holddata;
                        $holddata['title']='';
                        $records=array();
                        
                    }
                } else {
                    $final = array();
                }

//foreach()

//echo $count=count($final);

//echo '

';

$index=0; //print_r(array_filter($final)); foreach($final as $k=>$arr){

                foreach($arr as $key=>$value){
  $count=count($value);
  if($count==0){
      echo '<pre>';
      echo ' am empty object remove me ';
      '<br>';
      unset($arr[$index]);
      
      
  }

}

         $index++;       
                }


                ////FINAL DATA
                $allproducts = array("id" => $product->id,
                    "product_name" => $product->product_name,
                    "product_description" => $product->description,
                    "mrp" => $product->mrp,
                    "selling_price" => $product->selling_price,
                    "stock" => $product->stock,
                    "primary_image" => asset($product->primary_image),
                    "key_highlight" => $highlight,
                    "specification" => $productsspecification,
                    "features" => $productsfeatures,
                    "optional_images" => $productsphotos,
                    "product_attributes" => $final
                );
            }


            return response()->json(['data' => $allproducts], 200)->header('status', 200);
        } else {


            return response()->json(["message" => 'no product found'], 202)->header('status', 202);
        }
    }
}

`

Oct
05
1 year ago
Activity icon

Replied to How To Make Common Public Directory For Two Laravel Installation

Thanks for your reply aurawindsurfing the issue is now resolved by using helper function actually I am using images to website from my admin panel which is in separate laravel installation so when I update in admin I want to show that on-site too but laravel default asset function take URL of that installation only so that was the problem I override it with my custom helper function and solved my issue. thanks for your reply and Idea

Oct
04
1 year ago
Activity icon

Started a new Conversation How To Make Common Public Directory For Two Laravel Installation

My question is How to make a common public directory for two laravel installation I have two different laravel installation eg laravel1.com/laraadmin/ && 2nd laravel1.com/larawebsite/

I want to make a common public directory for CSS and js and images how can I set path in the website so i can show dynamic data from the database

Sep
14
1 year ago
Activity icon

Started a new Conversation Throttle On Ajax Request For Resent Otp

I want to put the throttle on ajax request so a user can't send otp again and again i don't have any idea how to do it any more suggestion

Aug
21
1 year ago
Activity icon

Replied to How To Make Mail Dynamic With Data From Table And Send Invoice Mail To Customer

I want to perform all the calculation on that view so it will be dynamic for everyone plz help me out

Activity icon

Started a new Conversation How To Make Mail Dynamic With Data From Table And Send Invoice Mail To Customer

I am trying to mail the invoice to the customer with there ordered data but unable to send data in a loop to view using dompdf i want to make item list dynamic here is my code

Controller:

 $restdetails = res_details::first();

   $data = ['resname' => $restdetails->resname];
   $varients = ['varient_name' => $restdetails->resname];
   $extras = ['extra_name' => $restdetails->resname];
 
   view()->share('admin.pdf.invoice',compact('data', 'extras', 'varients'));

    Mail::send(['html'=>'admin.pdf.invoice'], $data, function($message) use ($data,$extras,$varients) {

        $pdf = PDF::loadView('admin.pdf.invoice',compact('data', 'extras', 'varients'));

        $message->to('[email protected]','John Smith')->subject('Send Mail from Laravel');

        $message->attachData($pdf->output(), 'filename.pdf');

    });
   echo 'Email was sent!';

and my view is :

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Aloha!</title>

<style type="text/css">
    * {
        font-family: Verdana, Arial, sans-serif;
    }
    table{
        font-size: x-small;
    }
    tfoot tr td{
        font-weight: bold;
        font-size: x-small;
    }
    .gray {
        background-color: lightgray
    }
</style>

</head>
<body>

  <table width="100%">
    <tr>
        <td valign="top"><img src="{{asset('/public/logo.png')}}" alt="" width="150"/></td>
        <td align="right">
            <h3>INVOICE</h3>
            <pre>
              {{$data->resname}}
                
            </pre>
        </td>
    </tr>

  </table>

  <table width="100%">
    <tr>
        <td><strong>From:</strong>sdsdds</td>
        <td><strong>To:</strong> Linblum - Barrio Comercial</td>
    </tr>

  </table>

  <br/>

  <table width="100%">
    <thead style="background-color: lightgray;">
      <tr>
        <th>#</th>
        <th>Description</th>
        <th>Quantity</th>
        <th>Unit Price $</th>
        <th>Total $</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <th scope="row">1</th>
        <td>Playstation IV - Black</td>
        <td align="right">1</td>
        <td align="right">1400.00</td>
        <td align="right">1400.00</td>
      </tr>
      <tr>
          <th scope="row">1</th>
          <td>Metal Gear Solid - Phantom</td>
          <td align="right">1</td>
          <td align="right">105.00</td>
          <td align="right">105.00</td>
      </tr>
      <tr>
          <th scope="row">1</th>
          <td>Final Fantasy XV - Game</td>
          <td align="right">1</td>
          <td align="right">130.00</td>
          <td align="right">130.00</td>
      </tr>
    </tbody>

    <tfoot>
        <tr>
            <td colspan="3"></td>
            <td align="right">Subtotal $</td>
            <td align="right">1635.00</td>
        </tr>
        <tr>
            <td colspan="3"></td>
            <td align="right">Tax $</td>
            <td align="right">294.3</td>
        </tr>
        <tr>
            <td colspan="3"></td>
            <td align="right">Total $</td>
            <td align="right" class="gray">$ 1929.3</td>
        </tr>
    </tfoot>
  </table>

</body>
</html>



Jul
25
1 year ago
Activity icon

Started a new Conversation I Want To Show Count Of Subcategories In My Resource Collection List

here is my controller code :

$categories = categories::paginate(20);


foreach($categories as $category)
{
    
   
  $countcat = DB::table('subcats')->where('cat_id',$category->cat_id)->count(); 
   //echo $countcat;
  
 $categories->put('subcats', $countcat);
}
     
      return categoryResource::collection($collection);
        

Jul
17
1 year ago
Activity icon

Replied to How To Filter Array For Empty Value And Stop It Inserting Null Record In My Database

thanks snappy i have made some changes in my code now its working fine thanks for your valuable reply

Activity icon

Started a new Conversation How To Filter Array For Empty Value And Stop It Inserting Null Record In My Database

I am trying to filter an array for an empty value. Here is my code of controller.

    <?php 
    $extra = array();
    $extra = $request->extra;
    $extraprice = array();
    $extraprice = $request->extraprice;
    $rec = $request->rec;
    $variant = array();
    $variant = $request->vname;

    $variantprice = array();
    $variantprice = $request->vprice;

 /////filtering array for empty values///////////////////////////////////////
   
 $variant = array_filter($variant, function($value) {
        return $value !== '';
    });


    $variantprice = array_filter($variantprice, function($value) {
        return $value !== '';
    });




    $extra = array_filter($extra, function($value) {
        return $value !== '';
    });


    $extraprice = array_filter($extraprice, function($value) {
        return $value !== '';
    });


 if(!empty($variant) && !empty($variantprice)){
    $variantfinal = array_combine($variant, $variantprice);
}


    if(!empty($extra) && !empty($extraprice)){
$extrafinal = array_combine($extra, $extraprice);
 }
print_r($extrafinal);
exit();```


but when I print this it's not working but in core PHP it is working fine any suggestion for my code. thanks in advance
Jul
05
1 year ago
Activity icon

Replied to How To Add More Elements To A Resource Data Collection In REST API

thanks for your reply can you explain it in some code example ?

Jul
04
1 year ago
Activity icon

Started a new Conversation How To Add More Elements To A Resource Data Collection In REST API

i want to add more elements from different table to a resource data collection i have created first how can i do this with pagination here is my current code:

public function seefav(Request $request)
    {
      
      
      
      
      $validator = \Validator::make($request->all(), [
        'student_id'=> 'required',
             ]);
         if ($validator->fails()) {
            
            return Response::json(['message' => 'Empty values not allowed']);
        }else{
            
            
      if (favourites::where('student_id', $request->student_id)->exists()) {
          
          
          
        $student = favourites::where('student_id', $request->student_id)->get();
       
       
        foreach($student as $st){ 
             $quiz=$st->quiz_id;
            
            
        
        
       
        $resultsquiz = DB::select( DB::raw("SELECT * FROM quizzes WHERE quiz_id ='$quiz'") );
 
 foreach($resultsquiz as $resquiz){
     
      $quiz_image=asset($resquiz->quiz_image);
       $quiz_time=$resquiz->question_time;
       $life=$resquiz->life;
       $quiz_best=$resquiz->best_score;
       $quiz_name=$resquiz->quiz_name;
      $quizdata=array("quiz_name"=>$quiz_name,"quiz_image"=>$quiz_image); 
       
       
  }
        }
  
   return Response::json(['quiz' => $quizdata,'data'=>new FavouritesResource($student)]);  
   

///these comment code i tried but its not as i want the response in default data collection


        //return FavouritesResource::collection($student);
       //return FavouritesResource::collection($student)->additional([
            //'data' => [
           //     'id'=>$id,
            //    'quiz_name' => $quiz_name
           // ]
        //]); 
       
        
        
      }else{
      return Response::json(['message' => 'NO data found ']); 
    }
    
        }
} ```  
Jul
03
1 year ago
Activity icon

Started a new Conversation Edit API Response

i want to change my Api response without losing pagination and meta feature here is my code which am using right now

<?php 
public function seefav(Request $request)
    {
      
      
      //echo $request->student_id;
      
      $validator = \Validator::make($request->all(), [
        'student_id'=> 'required',
             ]);
         if ($validator->fails()) {
            
            return Response::json(['message' => 'Empty values not allowed']);
        }else{
            
            
      if (favourites::where('student_id', $request->student_id)->exists()) {
          
          
          
        $student = favourites::where('student_id', $request->student_id)->paginate(20);
        //print_r($student);
         // Return single list as a resource
        foreach($student as $st){ 
            $quiz=$st->quiz_id;
            
            
        }
       
        $resultsquiz = DB::select( DB::raw("SELECT * FROM quizzes WHERE quiz_id ='$quiz'") );
  foreach($resultsquiz as $resquiz){
      $id=$resquiz->id;
      $quiz_image=asset($resquiz->quiz_image);
       $quiz_time=$resquiz->question_time;
       $life=$resquiz->life;
       $quiz_best=$resquiz->best_score;
       $quiz_name=$resquiz->quiz_name;
       
       
       
  }
  
  
       
       
        //return FavouritesResource::collection($student);
       return FavouritesResource::collection($student)->additional([
            'data' => [
                'id'=>$id,
                'quiz_name' => $quiz_name
            ]
        ]); 
       
        
        
      }else{
      return Response::json(['message' => 'NO data found ']); 
    }
    
        }
} ```

i want to change my response to 

```{
  "data": {
    "0": {
      "id": 2,
      "quiz_name": "sumit",
      "quiz_image": "http://mobileappdatabase.in/quiz/",
      "quiz_id": "quiz_id_5b35bbb663bd0",
      "student_id": "SID31867"
    },
    "id": "1",
    "quiz_name": "Demo"
  },
  "links": {
    "first": "?page=1",
    "last": "?page=1",
    "prev": null,
    "next": null
  },
  "meta": {
    "current_page": 1,
    "from": 1,
    "last_page": 1,
    "path": "",
    "per_page": 20,
    "to": 1,
    "total": 1
  }
}````

this to this 


```{
  "data": {
    "0": {
      "id": 2,
      "quiz_name": "sumit",
      "quiz_image": "http://mobileappdatabase.in/quiz/",
      "quiz_id": "quiz_id_5b35bbb663bd0",
      "student_id": "SID31867",
      "quiz_name": "Demo"
    },
   
  },
  "links": {
    "first": "page=1",
    "last": "page=1",
    "prev": null,
    "next": null
  },
  "meta": {
    "current_page": 1,
    "from": 1,
    "last_page": 1,
    "path": "",
    "per_page": 20,
    "to": 1,
    "total": 1
  }
}```
Activity icon

Replied to Database Query

thanks for reply issue is resolved

Activity icon

Started a new Conversation Database Query

i want to know how to apply where with AND condition in following query what am missing

 public function addfav(Request $request)
    {
      
      
      //echo $request->student_id;
      
      if (favourites::where('student_id', $request->student_id)->where('quiz_id',  $request->quiz_id)->exists()) {
          echo 'studentid present';
           
          
          
          
      }else{
      $student = new favourites;
      $student->quiz_name=$request->quiz_name;
      $student->quiz_id=$request->quiz_id;
      $student->student_id=$request->student_id;
      $student->save();
 return Response::json(['message' => 'Quiz added to favourite list']);
       
    }
    ```
Jun
29
1 year ago
Activity icon

Replied to Exception Handling

yes thanks now its in development i will do that late thanks alot for your help i will take more help from u in future :)-

Activity icon

Replied to Exception Handling

yes now its working well i have forget something to add thanks a lot Yorki

Activity icon

Replied to Exception Handling

yes it works but i want it in JSOn format not exception like this here is my url

http://mobileappdatabase.in/radiolara/api/v1/token

Activity icon

Replied to Exception Handling

Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_ERROR) Class 'App\Http\Controllers\UnsecureException' not found

i have got this error now

Activity icon

Replied to Exception Handling

yes you right but when i try GET method i still got error not the response i made for it

Activity icon

Replied to Exception Handling

and what's wrong am doing in my way i have other api using same code there it work perfect but when i setup new project i have start getting this error

Activity icon

Replied to Exception Handling

is there any composer cmd for creation exception like this ?

Activity icon

Replied to Exception Handling

where to create class unsecured Exception ? i mean in which file ? in handler ?

Activity icon

Replied to Exception Handling

use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
class Handler extends ExceptionHandler
{
    protected $dontReport = [
        \Illuminate\Auth\AuthenticationException::class,
        \Illuminate\Auth\Access\AuthorizationException::class,
        \Symfony\Component\HttpKernel\Exception\HttpException::class,
        \Illuminate\Database\Eloquent\ModelNotFoundException::class,
        \Illuminate\Session\TokenMismatchException::class,
        \Illuminate\Validation\ValidationException::class,
    ];

   
    public function report(Exception $exception)
    {
        parent::report($exception);
    }

    
    public function render($request, Exception $exception)
    {
        if ($exception instanceof MethodNotAllowedHttpException) 
        {
            return response()->json( [
                                        'error' => 'Unauthenticated',
                                        'message' => 'Method is not allowed for security purpose',
                                        
                                    ], 404 );
        }

        return parent::render($request, $exception);
    }
} ```
Activity icon

Started a new Conversation Exception Handling

i want to show custom error on method not allowed exception so i have used this code but still igot error method not exception not my custom error this is my controller function

public function storetoken(Request $request){
       if ($request->isMethod('POST')) {
           echo  $method = $request->method();

  
    }else{
    
    return abort(404);
} ```

This is my handler for not allowed

Activity icon

Replied to How To Take Out Data From Response

thanks @yorki got your code now thanks for help

Activity icon

Replied to How To Take Out Data From Response

stdClass Object ( [multicast_id] => 5112366512282904862 [success] => 0 [failure] => 990 [canonical_ids] => 0 [results] => Array ( [0] => stdClass Object ( [error] => InvalidRegistration )

i want to get that success object but its not working even after decoding the json format

Activity icon

Replied to How To Take Out Data From Response

i have tried

$json = json_decode($result);

if (isset($json->success) && $json->success) { //This call was successfull }

but its showing blank no data in it but success has data

Activity icon

Replied to How To Take Out Data From Response

i am getting response from the api i want to check that if success object has value more then zero how to take that off from the response

{"multicast_id":5497393008180546563, "success":0, "failure":990, "canonical_ids":0, "results":[ {"error":"InvalidRegistration"} ]

Activity icon

Started a new Conversation How To Take Out Data From Response

'''function sendNotification($token,$dataArr) { $key = env('FCM_KEY',''); $fcmApiKey = $key; $url = 'https://fcm.googleapis.com/fcm/send';

    $registrationIds = $token;//Fcm Device ids array

    $message = $dataArr['message'];
    $title = $dataArr['title'];
    $image=$dataArr['image'];
    $news_id=$dataArr['station_id'];

$random=$dataArr['random_id'];

    $msg = array('message' => $message,'title' => $title,"image"=>$image,"station_id"=>$news_id,"random_id"=>$random);
    $fields = array('registration_ids' => $registrationIds,'data' => $msg);


    $headers = array(
        'Authorization: key=' . $fcmApiKey,
        'Content-Type: application/json'
    );

    $ch = curl_init();
    curl_setopt( $ch,CURLOPT_URL, $url );
    curl_setopt( $ch,CURLOPT_POST, true );
    curl_setopt( $ch,CURLOPT_HTTPHEADER, $headers );
    curl_setopt( $ch,CURLOPT_RETURNTRANSFER, true );
    curl_setopt( $ch,CURLOPT_SSL_VERIFYPEER, false );
    curl_setopt( $ch,CURLOPT_POSTFIELDS, json_encode( $fields ) );
    $result = curl_exec($ch );
    // Execute post
    $result = curl_exec($ch);
    if ($result === FALSE) {
        die('Curl failed: ' . curl_error($ch));
    }
    // Close connection
    curl_close($ch);    
   return $result;
   
    
    
}'''
Jun
27
1 year ago
Activity icon

Replied to How To Check For Empty Array

Thanks for your reply . yes it works .

Activity icon

Started a new Conversation How To Check For Empty Array

$gallery = DB::table('galleries')->where('store_id',$id)->get();

how to find that tha $gallery array is empty or not how to check this

Jun
21
1 year ago
Activity icon

Replied to Throttle Password Reset

if i want to add this to my defuth auth login controller does it work same without make any changes

Activity icon

Replied to Throttle Password Reset

after adding this .

i have to change anything else?

Activity icon

Replied to Throttle Password Reset

namespace App\Http\Controllers\Auth;

use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;

class ForgotPasswordController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Password Reset Controller
    |--------------------------------------------------------------------------
    |
    | This controller is responsible for handling password reset emails and
    | includes a trait which assists in sending these notifications from
    | your application to your users. Feel free to explore this trait.
    |
    */

    use SendsPasswordResetEmails;

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('guest');
    }
}

Activity icon

Replied to Throttle Password Reset

this is my forgetpassword controller

Activity icon

Started a new Conversation Throttle Password Reset

How can i add Throttle Password Reset in my reset controller?