localpathcomp

Software Engineer at Local Path Computing & Web Design

Member Since 8 Months Ago

Crystal Springs

Experience Points
6,770
Total
Experience

3,230 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
65
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 2
6,770 XP
Feb
20
1 week ago
Activity icon

Started a new Conversation How To Scope The OrWhere Query To The Original Relationship W/o Manually Writing It

The union query works great & is correct but seems quite slower.

$first = auth()->user()
                         ->notifications()
                          ->where('data->matter_id', 7);
                            
        $notifications = auth()->user()
                            ->notifications()
                            ->whereJsonContains('data->matters', 7)
                            ->union($first)->get();

How could I get the same result but in one orWhere? this won't have the requisite clauses added like the first where clause on the relationship without manually writing them in

$notifications = auth()->user()->notifications()
                            ->where('data->matter_id', 7)
                            ->orWhere(function($query) {
                                $query->where([
                                    ['notifiable_id', auth()->user()->id],
                                    ['notifiable_type', 'App\User'],
                                    ])
                                    ->whereNotNull('notifiable_id')
                                    ->whereJsonContains('data->matters', 7);
                            })->get();

The manual query is about 0.7ms the union is around 30ms so considerably slower. Seems like over 20x slower and that probably gets worse as the table grows larger

select
  *
from
  `notifications`
where
  `notifications`.`notifiable_id` = 960f462f-6a54-42ef-971d-ea3699992dda
  and `notifications`.`notifiable_id` is not null
  and `notifications`.`notifiable_type` = App\User
  and json_unquote(json_extract(`data`, '$."matter_id"')) = 7
  or (
    (
      `notifiable_id` = 960f462f-6a54-42ef-971d-ea3699992dda
      and `notifiable_type` = App\User
    )
    and `notifiable_id` is not null
    and json_contains(`data`, 7, '$."matters"')
  )
order by
  `created_at` desc

This is what the second manual query builds

Jan
28
1 month ago
Activity icon

Replied to Laravel Swift-mailer Exception “Expected Response Code 250 But Got An Empty Response” Using Gmail Smtp-relay (database Queue Driver)

should work once the cache is cleared?

this is my listener class

<?php

namespace App\Listeners;

use Illuminate\Mail\Events\MessageSending;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;

class SetDomainForSmtp
{
    /**
     * Create the event listener.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Handle the event.
     *
     * @param  MessageSending  $event
     * @return void
     */
    public function handle(MessageSending $event)
    {
        $_SERVER['SERVER_NAME'] = config('app.mail_domain') ?? '127.0.0.1';
    }
}

the event provider class

<?php

namespace App\Providers;

use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Event;
use App\Matter;
use App\User;
use App\Observers\MatterObserver;
use App\Observers\UserObserver;

class EventServiceProvider extends ServiceProvider
{
    /**
     * The event listener mappings for the application.
     *
     * @var array
     */
    protected $listen = [
        Registered::class => [
            SendEmailVerificationNotification::class,
        ],
        'Illuminate\Mail\Events\MessageSending' => [
            'App\Listeners\SetDomainForSmtp',
        ],
    ];

    /**
     * Register any events for your application.
     *
     * @return void
     */
    public function boot()
    {
        parent::boot();

        Matter::observe(MatterObserver::class);
        User::observe(UserObserver::class);
    }
}

Jan
27
1 month ago
Activity icon

Replied to Laravel Swift-mailer Exception “Expected Response Code 250 But Got An Empty Response” Using Gmail Smtp-relay (database Queue Driver)

that would be \etc\hosts for the entire server right? i had some entries mapped to it already but not my domain. im not super advanced in linux. @snapey have you tried this or have any tips for it? our server is provisioned via forge and it wont be multisite but you think it would cause any issues trying it?

Activity icon

Replied to Laravel Swift-mailer Exception “Expected Response Code 250 But Got An Empty Response” Using Gmail Smtp-relay (database Queue Driver)

/**
     * The event listener mappings for the application.
     *
     * @var array
     */
    protected $listen = [
        Registered::class => [
            SendEmailVerificationNotification::class,
        ],
        'Illuminate\Mail\Events\MessageSending' => [
            'App\Listeners\SetDomainForSmtp',
        ],
    ];

@fallenknight85 based on what you taught me i came up with this event driven method. add this to your event service provider, in the boot() for the listener (i made mine SetDomainForSmtp) you can set the global $_SERVER['SERVER_NAME'] in response to an email being sent. this hooks into the event before so its perfect for avoiding setting the global on other request-response cycles. seems to work great

Jan
26
1 month ago
Activity icon

Replied to Laravel Swift-mailer Exception “Expected Response Code 250 But Got An Empty Response” Using Gmail Smtp-relay (database Queue Driver)

It worked man. Thats so weird. You think thats the best place to set the $_SERVER['SERVER_NAME'] variable? Couldn't we set it config/app.php via an env()? THanks for the reply

Jan
25
1 month ago
Activity icon

Started a new Conversation Laravel Swift-mailer Exception “Expected Response Code 250 But Got An Empty Response” Using Gmail Smtp-relay (database Queue Driver)

the gmail smtp-relay works fine using the sync driver, but if we queue the email we this error. cleared config, cache, & restarted queue workers. tested in prod and dev, same results

[2021-01-24 20:04:22] production.ERROR: Expected response code 250 but got an empty response {"exception":"[object] (Swift_TransportException(code: 0): Expected response code 250 but got an empty response at /home/****/****/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php:448)

were wondering is this because of serialization and something is not making it through that process??? using latest stable release of laravel >8.0. gmail smtp is authenticating just fine, per why the sync driver sends emails easily. maybe there needs to be a timeout on the queue jobs so they dont barrage gmail so quickly? also our code works fine using sendgrid for example as the smtp relay. thanks.