jim1506

jim1506

Technical Director at London

Member Since 4 Years Ago

London, UK

Experience Points
8,360
Total
Experience

1,640 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
53
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 2
8,360 XP
Jan
09
4 months ago
Activity icon

Replied to Stripe And Cashier Help

Thanks. I will retry it and let you know. The version of the .js was from a tutorial!

Jan
08
4 months ago
Activity icon

Replied to Stripe And Cashier Help

Thanks. I am still a bit confused. So I get the customer info and save it and then use

$cu->createAsStripeCustomer();

and then pass details to the card form

return redirect()->route('formStarterPayment',['id' => $cu->id, 'intent' => $cu->createSetupIntent()]);

but the form is sending back as dd()

Illuminate\Http\Request {#43 ▼
  #json: null
  #convertedFiles: null
  #userResolver: Closure($guard = null) {#470 ▶}
  #routeResolver: Closure() {#472 ▶}
  +attributes: Symfony\Component\HttpFoundation\ParameterBag {#45 ▶}
  +request: Symfony\Component\HttpFoundation\ParameterBag {#44 ▼
    #parameters: array:4 [▼
      "_token" => "po0h3Y99nYZ0Qy9rK9TaNrdTB365cRKyEHzPXLHQ"
      "stripeToken" => "tok_1Fyf16F7aDMrgjaucGFx296w"
      "stripeTokenType" => "card"
      "stripeEmail" => "[email protected]"
    ]
  }
  +query: Symfony\Component\HttpFoundation\ParameterBag {#51 ▶}
  +server: Symfony\Component\HttpFoundation\ServerBag {#47 ▶}
  +files: Symfony\Component\HttpFoundation\FileBag {#48 ▶}
  +cookies: Symfony\Component\HttpFoundation\ParameterBag {#46 ▶}
  +headers: Symfony\Component\HttpFoundation\HeaderBag {#49 ▶}
  #content: null
  #languages: null
  #charsets: null
  #encodings: null
  #acceptableContentTypes: null
  #pathInfo: "/subscriptionPayment"
  #requestUri: "/subscriptionPayment"
  #baseUrl: ""
  #basePath: null
  #method: "POST"
  #format: null
  #session: Illuminate\Session\Store {#504 ▶}
  #locale: null
  #defaultLocale: "en"
  -preferredFormat: null
  -isHostValid: true
  -isForwardedValid: true
  basePath: ""
  format: "html"

Not quite certain where I am to get the setupIntent and payment_method

Activity icon

Started a new Conversation Stripe And Cashier Help

I am getting somewhat confused by Cashier and Stripe and a lot out there seems to be contradictory and older.

I am using a table Customer so I have set the .env accordingly. The initial form for customer just gets their name, email, country and password and then goes to a controller method:

$cu = new Customer;

        $cu->name = $request->name;
        $cu->email = $request->email;
        $cu->country = $request->country;
        $cu->plan_id = 3;
        $cu->password = Hash::make($request->password);
        $cu->save();

        $cu->createAsStripeCustomer();


        //make the ID a session variable
        session(['customer' => $cu->id]);

        return redirect()->route('formStarterPayment',['id' => $cu->id, 'intent' => $cu->createSetupIntent()]);

The Stripe ID is recorded in the database.

Next is the payment page. I have a table of plans so I get the information at the start of the view and pass in the cost and the customer's email:

<form action="/subscriptionPayment" method="POST">
  @csrf
  <script
          src="https://checkout.stripe.com/checkout.js" class="stripe-button"
          data-key="{{ env('STRIPE_KEY') }}"
          data-amount="{{ $amount }}"
          data-name="{{ $pl->name }}"
          data-email="{{ $fs->email }}"
          data-currency="gbp">
        </script>
</form>

This is where confusion starts as I am trying to set up a subscription.

if I dd($request) I get

"stripeToken" => "tok_1FybOgF7aDMrgjaugPzXdejn"
      "stripeTokenType" => "card"
      "stripeEmail" =>appropriate email

so my function is

    $tokenType = $request->stripeTokenType;
    $email = $request->stripeEmail;

    $stripeToken = $request->stripeToken;

    $cu = Cust::find( session('customer') );
    $pl = Plan::find(3);

    $cu->createOrGetStripeCustomer();

    $amount = $pl->cost *100;

    $cu->stripeToken = $stripeToken;
    $cu->save();

    $paymentMethod = $cu->paymentMethods();
    $intent = $cu->createSetupIntent();

    $cu->newSubscription($pl->name, $pl->test_stripe_plan)
        ->trialDays($pl->freePeriod)
        ->create($stripeToken,
          ['email' => $email]);

This fails with an error message that there is no such payment method and then the token is given.

I am using Laravel 5.8 with the latest Cashier and obviously I have checked what is the database and it is fine.

I will be grateful for any help!

Dec
30
5 months ago
Activity icon

Replied to Format Number Field In Yarja Datatables From Query

His site has been down for a few days, but Ok now. I just added the raw in the config and it is fine.

Thanks again

Activity icon

Replied to Format Number Field In Yarja Datatables From Query

The column is just a column of the symbol itself next to a column of the currency name. The database contains the hex database symbol so all I want to show is the symbol itself. In other words I want to get the string to show up as just html code.

Activity icon

Replied to Format Number Field In Yarja Datatables From Query

The idea is to show the symbol as no currency amount is shown. It is a table of countries that links to a lot of information and I have a table of currencies which links so it is a case of showing the symbol only.

Activity icon

Replied to Format Number Field In Yarja Datatables From Query

It is refusing to let me show the code as it is showing it as the euro symbol but it is the hex code 8364 with &# before and ; after

Activity icon

Replied to Format Number Field In Yarja Datatables From Query

If I may be so bold, I also have a field for currency formats, for example

'€'

I want them to show as (in this case) the euro symbol rather than the data

Activity icon

Replied to Format Number Field In Yarja Datatables From Query

Perfect - Thanks a lot.

Activity icon

Replied to Format Number Field In Yarja Datatables From Query

I have a slight problem with the conversion. For example a figure of 29121286 is showing up as 2,12,286, 26711 is showing up as 2,711 and 2986952 is showing up as ,98,952.

I placed the script in a general javascript file which I call from the app layout:

function formatNumber(num) {
  return num.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, ',')
}

and added this to my page in the datatables definition:

createdRow: function (row, data, dataIndex) {
                    if (data.population !== undefined) {
                        $(row).find('td:eq(4)').html(formatNumber(data.population));
                    }
                },
Activity icon

Replied to Format Number Field In Yarja Datatables From Query

Thanks. I have a slight problem. I copied the function into a helper which I use but I am getting

syntax error, unexpected ')', expecting variable (T_VARIABLE)

The function as I put it in is:

function formatNumber(num) {
  return num.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, ',');
}
Activity icon

Replied to Format Number Field In Yarja Datatables From Query

Thanks but I am now certain what you mean. I have tried adding selectRaw etc

Dec
29
5 months ago
Activity icon

Started a new Conversation Format Number Field In Yarja Datatables From Query

I am writing a searchable table which includes the area and population. Here is the basic query:

public function getCountryData()
  {
    $co = DB::table('countries')->leftJoin('country_detail','country_detail.country_id','=','countries.id')->addSelect(['countries.id','countries.name','country_detail.capital','country_detail.area','country_detail.iso3','country_detail.population','country_detail.currencyName','country_detail.phone','country_detail.continent'])->get();
    return Datatables::of($co)
    ->addColumn('action', function($co){
                            $btn = '<div style="float:right">
                            <a href="'. route('country.edit',$co->id) .'  " class="btn btn-outline-secondary btn-xs" title="edit" style="margin-right:.5em">'.getEditIcon().'</a><a href="'. route('country.show', $co->id) .'" class="btn btn-outline-secondary btn-xs" title="images" style="margin-right:.5em">'.getBinoculars().'</a>';

                             return $btn;
                     }) ->rawColumns(['action'])
                 ->make(true);

  }

All this works fine in my view except that the population field, for example, returns something like 29121286 and of course I want to format it so it is 29,121,286.

Can this be done in the query or something in Datatables itself?