bmcn99

Member Since 7 Months Ago

Experience Points
460
Total
Experience

4,540 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
0
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.

  • Community Pillar

    Earned once your experience points ranks in the top 10 of all Laracasts users.

Level 1
460 XP
Mar
10
1 month ago
Activity icon

Replied to The SQL Shown By My BelongsTo Relation Via ->toSql() Is Different Than What The Error Shows Immediately After Returning That Same Relationship

I found the problem, my CompletedOrderItem was returning a hasMany relationship instead of a HasOne instance for order(). I corrected that and then "return $this->hasOne(CompletedOrderItem::class, 'order_id', 'id');" was working for my Order model to return the corresponding CompletedOrderItem.

Activity icon

Replied to The SQL Shown By My BelongsTo Relation Via ->toSql() Is Different Than What The Error Shows Immediately After Returning That Same Relationship

This is already in production and has been working fine with regular SQL so I don't think I can easily change around the database structure to do that. Even the sql that it produces when I retrieve the sql with ->toSql() is correct: "select * from completed_orders_items where completed_orders_items.order_id = ?". Then it changes during the actual return which I don't understand at all.

Is there no way for eloquent to return the row from the completed_orders_items as it exists now?

Mar
09
1 month ago
Activity icon

Replied to The SQL Shown By My BelongsTo Relation Via ->toSql() Is Different Than What The Error Shows Immediately After Returning That Same Relationship

I put it in code blocks, which should make it clearer. I didn't realize it took out all the formatting previously.

Mar
08
1 month ago
Activity icon

Replied to The SQL Shown By My BelongsTo Relation Via ->toSql() Is Different Than What The Error Shows Immediately After Returning That Same Relationship

Sorry let me clarify, and these are poorly named so it doesn't help.

There is a CompletedOrder, which represents a payment, CompletedOrderItems, which tie together that payment to multiple orders.

CompletedOrder
ID || Bunch of columns

CompletedOrderItem
ID || Completed_Order_ID || Order_ID

Orders
ID || Bunch of columns

So there might be several rows in CompletedOrderItem which look like this:

CompletedOrderItem
ID	||completed_order_id	|| order_id
777 || 200 								|| 1250
778 || 200 								|| 1251
779 || 200 								|| 1252
Activity icon

Replied to The SQL Shown By My BelongsTo Relation Via ->toSql() Is Different Than What The Error Shows Immediately After Returning That Same Relationship

Sorry for the delay in getting back to you -- The foreign key would be 'order_id' within the CompletedOrderItem table. Is there a way I can check if eloquent recognizes this properly? I thought me supplying it to the completedOrderItem() function fulfilled that?

Mar
05
1 month ago
Activity icon

Started a new Conversation The SQL Shown By My BelongsTo Relation Via ->toSql() Is Different Than What The Error Shows Immediately After Returning That Same Relationship

I feel like I'm going a little crazy on this one. I have a base Order::class, which belongs to a CompletedOrderItem class which has multiple orders associated with it.

On my page I am trying to use "dd($Order->completedOrderItem)" to retrieve the completedOrderItem but doing so is causing an error with the following:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'orders.completed_order_item_id' in 'where clause' (SQL: select * from `orders` where `orders`.`completed_order_item_id` in (84368) and `orders`.`deleted_at` is null)

In Order.php:

public function completedOrderItem(){

       return $this->belongsTo(CompletedOrderItem::class, 'id', 'order_id');
}

And in CompletedOrderItem.php:

public function order(){
    return $this->hasMany(Order::class);
}

So I start debugging from there and in the completedOrderItem() function within Order.php I do the following:

dd($this->belongsTo(CompletedOrderItem::class, 'id', 'order_id')->toSql());

which shows the following on my page:

"select * from `completed_orders_items` where `completed_orders_items`.`order_id` = ?"

That's strange. That's the SQL i expected, and if I get the bindings as well it's looking for the correct order_id, 227800.

I have no idea how the query changes from the correct ""select * from completed_orders_items where completed_orders_items.order_id = 227800" to the very incorrect "select * from orders where orders.completed_order_item_id in (84368) and orders.deleted_at is null" after simply being returned.

84368 is the corresponding completedOrderItem id btw.

Can anyone shed some light on what I'm doing wrong here, or what's going on? Much appreciated!

Jan
22
2 months ago
Activity icon

Replied to Drilling Down To Get All Meals() Relations Of A BelongToMany Relationship

$user = User::with('users_school.restaurants.meals')->find(user_id);

That's close to what I want, as it's getting the meals information, but I'd like to discard everything else and just retrieve the meals information. I think right now I'd have to set up a series of foreach loops to get at the meal info to display the menu. Is that possible?

Jan
21
2 months ago
Activity icon

Started a new Conversation Drilling Down To Get All Meals() Relations Of A BelongToMany Relationship

I have a user, who belongs to a singular school, which has multiple restaurants, and I want to get the meals related to each of those restaurants. Previously there was one restaurant per school and I could use the following successfully (where $this is User):

$meals = $this->users_school()->restaurants->first()->meals()
                ->where('additional constraints here')
                ->get();

I'm having a boatload of trouble figuring out how to get the meals for each restaurant now that I need to get the meals relation from multiple restaurants and can't rely on using first() to just work with one of them.

Is this possible or would I have to retrieve the restaurants first, and then do a follow up loop to get the meals from each of them that way?

Dec
16
4 months ago
Activity icon

Awarded Best Reply on I Am Seeing A New Security Issue In Chrome While Using Laravels Default Login Setup

If anyone else comes across this I implemented the fix found here: https://web.archive.org/web/20180423193212/http://www.code-examples.com/laravel-5-ssl-routes-behind-a-load-balancer/ and just needed to change the namespace to include App\ at the start.

The problem seems to be the way that Laravel/Symfony interacts with a load balancer like CloudFlare, and in some circumstances loses its ability to accurately determine that it is in a secure environment. The fix in that post implements an extension to Laravels Request class that overrides the isSecure function, which originally comes from Symfony.

I'm not sure if there was a simpler fix for this now that I understand the problem, reading more into Symfony I found something about changing the headers for setTrustedProxies(), but in my environment it was already set to HEADER_X_FORWARDED_ALL. Hope that helps someone anyway.

Activity icon

Replied to I Am Seeing A New Security Issue In Chrome While Using Laravels Default Login Setup

If anyone else comes across this I implemented the fix found here: https://web.archive.org/web/20180423193212/http://www.code-examples.com/laravel-5-ssl-routes-behind-a-load-balancer/ and just needed to change the namespace to include App\ at the start.

The problem seems to be the way that Laravel/Symfony interacts with a load balancer like CloudFlare, and in some circumstances loses its ability to accurately determine that it is in a secure environment. The fix in that post implements an extension to Laravels Request class that overrides the isSecure function, which originally comes from Symfony.

I'm not sure if there was a simpler fix for this now that I understand the problem, reading more into Symfony I found something about changing the headers for setTrustedProxies(), but in my environment it was already set to HEADER_X_FORWARDED_ALL. Hope that helps someone anyway.

Dec
15
4 months ago
Activity icon

Replied to I Am Seeing A New Security Issue In Chrome While Using Laravels Default Login Setup

No reply from him since yesterday unfortunately.

I'm still digging around in the laravel code to find how I can correct this but not having any luck at all. Somewhere in the redirect chain it's setting the path to http instead of https.

It's maybe happening during the logout process and setting a cachedScheme of http despite everything in place to prevent that, based on the debugging I've been able to do. When I first get to the site and log in it's fine. Subsequent login attempts always visit the http redirect however.

The login and logout functions now explicitly passes in a $secure=true flag for their redirects. This doesn't do a thing unfortunately. Since I can't get the forceScheme setting to be respected in some part of the code I'm not sure what else to do besides go into the core files and start changing the defaults on some of these functions so that $secure is set to true instead of null.

Dec
14
4 months ago
Activity icon

Started a new Conversation I Am Seeing A New Security Issue In Chrome While Using Laravels Default Login Setup

This appears to be this problem at its core: https://bugs.chromium.org/p/chromium/issues/detail?id=1158169

A customer reported it this morning and while unable to initially reproduce it, I am now seeing it myself too when logging into the site.

I'm using Laravel 7 and use URL::forceScheme('https'); in AppServiceProvider's boot function, which has worked fine until today.

When I use the default laravel login form I get the error mentioned in that thread, and if I choose "Send anyway" and look at the network traffic I do see: Status Protocol Scheme 301 http/1.1 http

As the first entry, followed by 100% https entries.

Has anyone else encountered this yet? I'm not sure how to move forward from here.