Saturday, July 17, 2021

curl request example

  $data = [

"registration_ids" => $firebaseToken,

"notification" => [

"title" => $request->title,

"body" => $request->body,

]

];

$dataString = json_encode($data);

$headers = [

'Authorization: key=' . $SERVER_API_KEY,

'Content-Type: application/json',

];

    Example 1:

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://fcm.googleapis.com/fcm/send');

curl_setopt($ch, CURLOPT_POST, true);

curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

curl_setopt($ch, CURLOPT_POSTFIELDS, $dataString);

$response = curl_exec($ch);


      Example 2:

 
      curl --request POST \
--url http://localhost:8000/api/login \
--header 'Accept: aplication/json' \
--header 'Content-Type: application/json' \
--data '{
"email":"user@hydra.project",
"password":"Surprisingly A Good Password"
}'


 Example 3:
curl --request GET \
--url http://localhost:8000/api/greet \
--header 'Accept: application/json' \
--header 'Authorization: Bearer 5|gbiWdd7yJFYiTIgoK1jK3C7HZJtJUK1PnBIToBLN

        

Improving PHP Code Quality with PHP CodeSniffer

 https://www.twilio.com/blog/improving-php-code-quality-php-codesniffer-phpcs-laravel


https://www.twilio.com/blog/set-up-php-codesniffer-local-development-sublime-text-php-storm-vs-code

Wednesday, July 7, 2021

Rating review code in vue js

data() {
    return {
      rating: 0,
      commentText: "",
      recentComments: [],
      ratingItems: [
        { id: 1, Scale: 5, Count: 0, bar_value: 0 },
        { id: 2, Scale: 4, Count: 0, bar_value: 0 },
        { id: 3, Scale: 3, Count: 0, bar_value: 0 },
        { id: 4, Scale: 2, Count: 0, bar_value: 0 },
        { id: 5, Scale: 1, Count: 0, bar_value: 0 },
      ],

      commentItems: [
        {
          id: 1,
          name: "Fahim Ahmed",
          image: "john.jpg",
          rating: 5,
          date: "02 June 2020",
          desc: "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.",
        },
        {
          id: 2,
          name: "Fahim Ahmed",
          image: "john.jpg",
          rating: 5,
          date: "02 June 2020",
          desc: "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.",
        },
      ],
    };
  },

computed: {
    totalPersonReted() {
      var total = 0;
      this.ratingItems.forEach((element) => {
        total += element.Count;
      });
      return total;
    },
    ratingTotalCount() {
      var total = 0;
      this.ratingItems.forEach((element) => {
        total += element.Count * element.Scale;
      });
      return total;

    },
    ratingAvg() {
      var avarage = (this.ratingTotalCount / this.totalPersonReted).toFixed(1);
      return parseFloat(avarage);
    },
  },
  
   methods: {
   // this method not needed any more
    submitcomments() {
      this.commentItems.unshift({
        id: this.commentItems.length + 1,
        name: "Md. Mobarak Ali",
        image: "",
        rating: this.rating,
        date: "02 June 2020",
        desc: this.commentText,
      });
      this.ratingItems.find((element) => {
        if (element.Scale == Math.ceil(this.rating)) {
          element.Count += 1;
        }
      });
      this.rating = 0;
      this.commentText = "";
    },
getBarTotal(item) {
      return Math.ceil((item.Count * 100) / this.totalPersonReted);
    },
   }
  
 

Wednesday, June 30, 2021

Add more div in vue js and jquery

IN VUE JS
 var demo = new Vue({

  el: '#demo',
  data: {
    counter: 0,
    inputs: [{
      id: 'fruit0',
      label: 'Enter Fruit Name',
      value: '',
    }],
  },
  methods: {
    addInput() {
      this.inputs.push({
        id: `fruit${++this.counter}`,
        label: 'Enter Fruit Name',
        value: '',
      });
    }
  }
});
<script src="https://unpkg.com/vue@2.5.16/dist/vue.js"></script>
<div id="demo">
  <div class="inputArea" v-for="input in inputs" :key="input.id">
    <label :for="input.id">{{input.label}}</label>
    <input :id="input.id" v-model="input.value"></input>
  </div>
  <button @click="addInput">Add input</button>
</div>
IN Jquery

<html lang="en">

<head>

<title>Bootstrap Jquery Add More Field Example</title>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js"></script>

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">

</head>

<body>


<div class="container">

<div class="panel panel-default">

<div class="panel-heading">Bootstrap Jquery Add More Field Example</div>

<div class="panel-body">


<form action="action.php" >


<div class="input-group control-group after-add-more">

<input type="text" name="addmore[]" class="form-control" placeholder="Enter Name Here">

<div class="input-group-btn">

<button class="btn btn-success add-more" type="button"><i class="glyphicon glyphicon-plus"></i> Add</button>

</div>

</div>


</form>


<!-- Copy Fields -->

<div class="copy hide">

<div class="control-group input-group" style="margin-top:10px">

<input type="text" name="addmore[]" class="form-control" placeholder="Enter Name Here">

<div class="input-group-btn">

<button class="btn btn-danger remove" type="button"><i class="glyphicon glyphicon-remove"></i> Remove</button>

</div>

</div>

</div>


</div>

</div>

</div>


<script type="text/javascript">


$(document).ready(function() {


$(".add-more").click(function(){

var html = $(".copy").html();

$(".after-add-more").after(html);

});


$("body").on("click",".remove",function(){

$(this).parents(".control-group").remove();

});


});


</script>


</body>

</html>