matttonks11

matttonks11

Member Since 1 Year Ago

Experience Points
25,160
Total
Experience

4,840 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
220
Lessons
Completed
Best Reply Awards
3
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 6
25,160 XP
Sep
12
1 month ago
Activity icon

Replied to Curl Error 6 On Production Server

@stefanbauer Okay I'll take a look, thanks for your help

Sep
11
1 month ago
Activity icon

Replied to Curl Error 6 On Production Server

The server itself is an on-premise server and my workplace has a proxy, would this affect it in anyway?

Activity icon

Replied to Curl Error 6 On Production Server

@stefanbauer Here's the output from nslookup & dig

nslookup graph.microsoft.com
Server:     127.0.0.53
Address:    127.0.0.53#53

Non-authoritative answer:
graph.microsoft.com canonical name = prd.ags.msidentity.com.
prd.ags.msidentity.com  canonical name = www.ags-prd.akadns.net.
Name:   www.ags-prd.akadns.net
Address: 20.190.143.50
Name:   www.ags-prd.akadns.net
Address: 20.190.143.52
Name:   www.ags-prd.akadns.net
Address: 20.190.143.51
Name:   www.ags-prd.akadns.net
Address: 20.190.143.49
; <<>> DiG 9.11.3-1ubuntu1.9-Ubuntu <<>> graph.microsoft.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 28346
;; flags: qr rd ra; QUERY: 1, ANSWER: 6, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;graph.microsoft.com.       IN  A

;; ANSWER SECTION:
graph.microsoft.com.    3030    IN  CNAME   prd.ags.msidentity.com.
prd.ags.msidentity.com. 175 IN  CNAME   www.ags-prd.akadns.net.
www.ags-prd.akadns.net. 167 IN  A   20.190.143.49
www.ags-prd.akadns.net. 167 IN  A   20.190.143.50
www.ags-prd.akadns.net. 167 IN  A   20.190.143.52
www.ags-prd.akadns.net. 167 IN  A   20.190.143.51

;; Query time: 2 msec
;; SERVER: 127.0.0.53#53(127.0.0.53)
;; WHEN: Wed Sep 11 14:22:09 UTC 2019
;; MSG SIZE  rcvd: 181

Activity icon

Replied to Curl Error 6 On Production Server

Hi here's the specific error code and the code used

cURL error 6: Could not resolve host: graph.microsoft.com (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)


 public function handleOauthResponse()
    {
        $user = Socialite::driver('azure-oauth')->user();

        $authUser = $this->findOrCreateUser($user);

        auth()->login($authUser, true);

        return redirect(
            config('azure-oath.redirect_on_login')
        );
    }

I looked through the stack trace and this is the code used by the socialite package I installed.

protected function getUserByToken($token)
    {
        $response = $this->getHttpClient()->get('https://graph.microsoft.com/v1.0/me/', [
            'headers' => [
                'Authorization' => 'Bearer '.$token,
            ],
        ]);
 
        return json_decode($response->getBody(), true);
    }

What's weird is it works sometimes on the production server, but works every time on the digital ocean droplet I set up

Activity icon

Started a new Conversation Curl Error 6 On Production Server

Hi there,

I'm having issues with my web applications deployed via forge on a VPS i have set up.

I will randomly get a curl error 6 - could not resolve host when doing things like trying to log users in via a Socialite package. At first I thought it was an issue with the code but I set the same project up on a Digital Ocean droplet and there aren't any issues.

Does anybody know of any issues, more importantly any checks or fixes I could be doing?

Any help would be majorly appreciated

Jun
11
4 months ago
Activity icon

Replied to A Non Well Formed Numeric Value Encountered On Laravel Excel Package

Hi, I used this function in one of my projects, just add it to your import class

private function transformDateTime(string $value, string $format = 'Y-m-d')
{
     try {
            return Carbon::instance(Date::excelToDateTimeObject($value))->format($format);
         } catch (\ErrorException $e) {
            return Carbon::createFromFormat($format, $value);
         }
}

You'll have to import Carbon\Carbon and the PhpOffice\PhpSpreadsheet\Shared\Date classes

To use it just change the line you have currently to

    $this->transformDateTime($row[3])

You can add a second argument to change the date's format if you need.

Jun
05
4 months ago
Activity icon

Replied to Returning First() With Maatwebsite/laravel-excel

If your exporting a collection you need to update your class

use Maatwebsite\Excel\Concerns\FromCollection;

class SuppliersExport implements FromCollection
{
  
    public function collection()
    {
        return Supplier::query()->where('user_id', auth()->id())->latest()->first();
    }
}

You can see more here https://docs.laravel-excel.com/3.1/exports/collection.html

Activity icon

Replied to Query Relationships In Laravel

Also relationships are generally there for ease of use I believe, so things like readability, it also saves you writing out that join statement multiple times in your codebase.

Activity icon

Replied to Query Relationships In Laravel

Hi, are you sure everything is correct with spelling? Does the rest of the query work if you temporarily remove that line?

 DB::raw('MIN(carts.ca_numlineitems) as items')

Activity icon

Replied to Query Relationships In Laravel

Hi, you should try

$vouchers = Voucher::with('cart.lineItems');

Since the cart model is the one with the lineItems relationship and not the Voucher model. You can then chain the rest of the methods like so

$vouchers = Voucher::with('cart.lineItems')
->whereBetween('vouchers.vchlastmodmsec', [$fromDate, $toDate])
->groupBy(['redeemed_date', 'order_date', 'order_id', 'settlement_status'])

I'm pretty sure you can use ```when()`` instead of the IF statements also if you prefer

see more here https://laraveldaily.com/less-know-way-conditional-queries/

So it looks something like this...

$query = Voucher::with('cart.lineItems')
->whereBetween('vouchers.vchlastmodmsec', [$fromDate, $toDate])
->groupBy(['redeemed_date', 'order_date', 'order_id', 'settlement_status']);

$query->when($request->filled('brand') && $request->input('brand'), function ($query) use($request) {
    return $query->where('carts.ca_brandid', $request->input('brand'));
})

$query->when($request->filled('city') && $request->input('city'), function ($query) use($request) {
    return $query->where('carts.ca_redmcitycode', $request->input('city'));
});

$vouchers = $query->get();