GrahamMorbyDev

GrahamMorbyDev

Full Stack PHP Developer at Movemee Ltd

Member Since 4 Years Ago

Stevenage UK

Experience Points
17,470
Total
Experience

2,530 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
110
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 4
17,470 XP
Jul
28
1 month ago
Activity icon

Replied to Stop GTM Running If Adblocker Is Present

The issue is it blocks and then stops any further scripts running

It's a very strange issue

Activity icon

Started a new Conversation Stop GTM Running If Adblocker Is Present

Im loading GTM into the head of my site with an iframe

<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-TAG"
    height="0" width="0" style="display:none;visibility:hidden" id="gtmanager"></iframe></noscript>

Now if an ad blocker is present I want to remove it or stop it loading, I have a function I'm loading at the bottom of the page, but it seems as tho because it runs before the DOM is loaded I can't access the iframe itself

<script>
    let adBlockEnabled = false;
    const ad = document.createElement('div');
    ad.innerHTML = '&nbsp';
    ad.className = 'adsbox';
    document.body.appendChild(ad);
    window.setTimeout(function() {
        if (ad.offsetHeight === 0) {
            adBlockEnabled = true;
        }
        if(adBlockEnabled == true) {
            console.log('ragnar')
        }
        ad.remove();
        console.warn('Blocking ads?', adBlockEnabled)
    }, 100);
</script>

Does anyone have any suggestions?

Apr
03
5 months ago
Activity icon

Replied to Stripe Elements Mounted Vs Method

@martinbean you sir are my hero and have saved me! Perfect answer and perfect explanation! Thank you so much

Apr
02
5 months ago
Activity icon

Replied to Stripe Elements Mounted Vs Method

@martinbean

My Stripe component is as follows

<template>
  <div>
    <label for="card-element">Credit or debit card</label>
    <div id="card-element" ref="cardElement">
      <!-- A Stripe Element will be inserted here. -->
    </div>

    <!-- Used to display form errors. -->
    <div id="card-errors" role="alert"></div>
    <button class="btn btn-primary mt-3" v-on:click="triggerPay()">Pay £{{amountprop / 100}}</button>
  </div>
</template>
<script>
export default {
  components: {},
  props: ["amountprop"],
  data() {
    return {
      cardElement: null,
      stripe: null,
      stripe_pk: "secret",
      test: process.env.STRIPE_PK
    };
  },
  mounted() {
    // Create a Stripe client.
    const stripe = window.Stripe(this.stripe_pk);
    // Create an instance of Elements.
    var elements = stripe.elements();
    // Create an instance of the card Element.
    var style = {
      base: {
        color: "#32325d",
        fontFamily: '"Helvetica Neue", Helvetica, sans-serif',
        fontSmoothing: "antialiased",
        fontSize: "16px",
        "::placeholder": {
          color: "#aab7c4"
        }
      },
      invalid: {
        color: "#fa755a",
        iconColor: "#fa755a"
      }
    };
    var card = elements.create("card", { style: style });

    // Handle real-time validation errors from the card Element.
    card.addEventListener("change", function(event) {
      var displayError = document.getElementById("card-errors");
      if (event.error) {
        displayError.textContent = event.error.message;
      } else {
        displayError.textContent = "";
      }
    });
    // Add an instance of the card Element into the `card-element` <div>.
    card.mount(this.$refs.cardElement);
  },
  created() {},
  computed: {},
  methods: {
    triggerPay() {
      this.$emit("triggerPay");
    },
    cardPayment(client_secret, data) {
        console.log(client_secret);
        console.log(data);
        Stripe.handleCardPayment(client_secret, data).then(function(result) {
            console.log(result)
        });
    }
  },
  watch: {}
};
</script>
<style>
</style>

Then the pay button fires an event and triggers the method

Which contains

this.$refs.stripeCardElement
            .cardPayment(response.data.data.client_secret, card)

So I feel like I'm back in the same place as the cardPayment() method isn't aware of the mounted stuff

Also to clarify I'm loading stripe as a JS Script in the head element

Activity icon

Replied to Stripe Elements Mounted Vs Method

I think it makes sense

mounted() {
    this.cardElement.mount(this.$refs.cardElement);
  },

This Im guessing is the reference point and the parent picks this up here

this.$refs.stripeCardElement.confirmCardPayment

Am I on the right track??

Activity icon

Started a new Conversation Stripe Elements Mounted Vs Method

Hey Guys

I have a mounted Stripe element that Im loading on the mounted() hook

 // Create a Stripe client.
    const stripe = Stripe("secret");

    // Create an instance of Elements.
    const elements = stripe.elements();
    // Create an instance of the card Element.
    const style = {
      base: {
        color: "#32325d",
        fontFamily: '"Helvetica Neue", Helvetica, sans-serif',
        fontSmoothing: "antialiased",
        fontSize: "16px",
        "::placeholder": {
          color: "#aab7c4"
        }
      },
      invalid: {
        color: "#fa755a",
        iconColor: "#fa755a"
      }
    };

    let card = elements.create("card", { style: style });
    // Add an instance of the card Element into the `card-element` <div>.
    card.mount("#card-element");

    // Handle real-time validation errors from the card Element.
    card.addEventListener("change", function(event) {
      var displayError = document.getElementById("card-errors");
      if (event.error) {
        displayError.textContent = event.error.message;
      } else {
        displayError.textContent = "";
      }
    });

Standard one from the docs

I then roll a method to do a payment intent and handle the card payment

So my issue is that the below code doesn't seem to be aware of the stripe instance

 let card = Element;
          if (selectedCard) {
            card = {
              payment_method: selectedCard
            };
          }

          //var stripe = Stripe("secret");
          stripe.handleCardPayment(response.data.data.client_secret, card).then(function(result) {
                console.log(result)
            });

Is there a way to have the whole page be aware of that mounted instance, I have tried adding them to data points to no avail

Thanks

Apr
01
5 months ago
Activity icon

Awarded Best Reply on Vue Persist Not Working On Page Reload

So I fixed the following, the issue seemed to be my array

so instead of

array: []

I had to go for

Object: {}

And now it all works great

Activity icon

Replied to Vue Persist Not Working On Page Reload

So I fixed the following, the issue seemed to be my array

so instead of

array: []

I had to go for

Object: {}

And now it all works great

Mar
27
5 months ago
Activity icon

Started a new Conversation Vue Persist Not Working On Page Reload

Hey Guys

I have installed vue-persist and loading it via vuex.

Every stores ok yet when I reload the browser nothing is being persisted back to the store.

import VuexPersist from "vuex-persist";

const vuexLocal = new VuexPersist({
    key: 'App',
    storage: window.localStorage
  });

export default{
    state: {
        pageTitle: "",
	array: []
      },
    getters:{
        getPageTitle(state) {
            return state.pageTitle;
        }
    },
    actions: {},
    mutations:{
        pageTitle(state, payload) {
            this.state.pageTitle = payload
        },
       },
    plugins: [vuexLocal.plugin]
}

Any help would be grateful