JohnBeales

JohnBeales

Member Since 8 Months Ago

Experience Points 10,630
Experience Level 3

4,370 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 104
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

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

22 Feb
2 months ago

JohnBeales left a reply on Three Way Relationship Or Relationship With A Relationship?

@ROERJO - That's what I'm going to so.

I looked at the Pivot model source, and it just inherits from the main Model with an extra Pivot trait, but I'm guessing that's what's used behind the scenes anyway, so by defining my own that inherits from that it shouldn't be much of a performance hit.

JohnBeales left a reply on Three Way Relationship Or Relationship With A Relationship?

@SHEZ1983 - It's more like:

  1. shops can do x services
  2. Some services are available for only some brands, but not others, (still on the Cars example, a garage needs computer software from Ford to turn off your Ford's Check Engine light, so they might offer "Turn off Check Engine Light" for Ford, but not Chevy).

Someone in Slack pointed me at the fact that when making the "wasteful" providesService model I would probably be extending a Illuminate\Database\Eloquent\Relations\Pivot object, which I'm guessing is used behind the scenes anyway, so it's less wasteful than I had thought. I'm going to give that a shot and see how it works.

JohnBeales left a reply on Three Way Relationship Or Relationship With A Relationship?

@ROERJO - I looked at hasManyThrough, and it doesn't seem to quite work. If I take the "wasteful" approach of making a ProvidesService model then I'll be able to use hasManyThrough to get the brands that a Shop can service, which may be useful.

21 Feb
2 months ago

JohnBeales started a new conversation Three Way Relationship Or Relationship With A Relationship?

I'm puzzling over how to set up this relationship in Laravel, (I'm converting a legacy app):

I have Repair Shops, which provide different types of repairs, on different brands of vehicles.

For example, Shop A might repair Brakes but not Exhaust Systems for Ford vehicles. Shops are required to say what services they provide, (Exhaust repair), but adding a brand is optional. I have Shop, Service, and Brand tables in the DB. Shop and Service have a belongsToMany relationship using the provides_service pivot table. In the legacy system I have a 3-way pivot table to specify what Services can be done to each Brand in each Shop.

Laravel doesn't seem to do 3-way relationships well, (or does it? If so, point me there!). So, I feel like it would make sense to create a belongsToMany between the provides_service relation and the Brand. So, is there a way to set up a relationship between a Model and another Relationship in Laravel, or do I have to create a ProvidesService model? Creating a ProvidesService model seems wasteful, but I'm not sure what else to do here.

23 Oct
6 months ago

JohnBeales left a reply on Output An Exact String In Blade Template

So it looks like I could subclass Illuminate\Notifications\ChannelManager, overriding the createMailDriver() method, and instead of using an instance of MailChannel, use a subclass of MailChannel. Then I could override the MailChannel::buildMessage() method and do the replacement in there, because it's passed as the callback that the Mailer calls to process the message one last time before it's sent.

So now the question becomes: How do I tell Laravel to use my custom ChannelManager class instead of Illuminate\Notifications\ChannelManager?

(There's also an "is it worth it" question).

JohnBeales left a reply on Output An Exact String In Blade Template

I tried inlining & had the same problem.

I could put in my own placeholders but can't figure out where to put them once the inlining is done. Do you know if there's an event that happens just before a Notification is sent via E-mail? Ideally I could get the SwiftMessage, or at least something that happens after the message content is completely ready.

JohnBeales left a reply on Output An Exact String In Blade Template

Hi! The <% %> won't eve be parsed by PHP, I want them to exist in the HTML when it gets sent to Sendgrid, where they'll grep the HTML and replace the <% %> part with the correct unsubscribe link.

I did try @verbatim and it didn't work.

I found what's happening. When using Markdown messages, the CSS is inlined by the CssToInlineStyles class. The method it uses is parsing the HTML string PHP's built-in DOMDocument, doing inlining on the DOM nodes using DOMDocument methods, then using DOMDocument::saveHTML() to get an updated HTML string. When parsing the input string DOMDocument sees the <%, thinks it's a non-existent HTML tag, and ignores it, so when the ->saveHTML() call happens later the <% %> isn't gone, (because it isn't in the DOMDocument internal representation of the document). I tested it by writing a CSS "inliner" that just passes the HTML string straight through - and the <% %> tags come out fine - but also the CSS isn't inlined, and it looks like it would be nearly impossible to implement a custom inliner in the Markdown class without a whole lot of work, (although if you know an easy way, I'm interested).

I think the path of least resistance is: 1) Do nothing right now and let SendGrid add their uglier unsubscribe links to the end of my HTML message, then 2) Use actual Mailable instances for the messages I want to use. They don't appear to pass through the same CSS inlining process, and even if they do I should have more control over them.

JohnBeales left a reply on Output An Exact String In Blade Template

It's not in the page source - see the comments in the first code block above for the output in the page source.

I have found where it's being stripped - it's happening when the CSS is inlined. I haven't found how to fix it yet, though.

JohnBeales started a new conversation Output An Exact String In Blade Template

I am trying to add replacement tags for Sendgrid, (they look like this: <%asm_preferences_url%>), to my Blade template that's used in HTML E-mails. However, they are getting removed, (maybe because they look like invalid HTML tags).

Is there a way to tell Laravel or Blade, “hey, output this string exactly as it is and leave it alone”? I have tried ed `{!! '<%asm_preferences_url%>' but it gets stripped out. With th `{{ '<%asm_preferences_url%> the < and > get turned into HTML entities, which are not recognized by Sendgrid.

Things I've tried:

<p>{!! '<%asm_preferences_url%>' !!}</p>  // becomes <p></p>
<p>{{ '<%asm_preferences_url%>' }}</p>    // becomes <p>&lt;%asm_preferences_url%&gt;</p>  
<p><%asm_preferences_url%></p>            // becomes <p></p>

Desired output:

<p><%asm_preferences_url%></p>

When I look at the compiled blade template it contains this, (when using the first method under "Things I've tried" above):

<?php echo '<%asm_preferences_url%>'; ?>

Which seems correct, so the string must be removed after compilation.

JohnBeales left a reply on Wordpress Front-end & Laravel In A Subfolder Issues

More detail would help. What happens, and what’s the problem exactly?

For example, if you go to goso.io/some-wp-url does it work as expected?

How about goso.io/account/some-laravel-route? If not, what happens?