bradycharron

Member Since 2 Years Ago

Experience Points
230
Total
Experience

4,770 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
1
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
230 XP
Mar
24
2 weeks ago
Activity icon

Awarded Best Reply on Queued Mailable Not Pushed To Queue

After some internal troubleshooting and discussion, we found that the problem was with the test assertion. I was asserting on the Queue fake, but should have been asserting on the Mail fake

The test should look like so, which is working:

Mail::fake();

$this->job->handle();

Mail::assertQueued(TestMailable::class, 1);
Activity icon

Replied to Queued Mailable Not Pushed To Queue

After some internal troubleshooting and discussion, we found that the problem was with the test assertion. I was asserting on the Queue fake, but should have been asserting on the Mail fake

The test should look like so, which is working:

Mail::fake();

$this->job->handle();

Mail::assertQueued(TestMailable::class, 1);
Mar
23
3 weeks ago
Activity icon

Started a new Conversation Queued Mailable Not Pushed To Queue

I am attempting to queue a mailable, and it is not being queued. I have the following:

Here is my mailable class:

<?php declare(strict_types=1);

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;

/**
 * Test Mailable
 */
class TestMailable extends Mailable implements ShouldQueue
{
    use Queueable;
    use SerializesModels;

    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        return $this->subject('Test Subject')
            ->markdown('emails.basic');
    }
}

This is the code in a job that calls the mailable:

$contacts->each(function ($recipient) {
    $message = new TestMailable();
    
    Mail::to($recipient)
        ->send($message);
});

I have the QUEUE_CONNECTION env variable set to database, and have provisioned the jobs table with the queue:table artisan command and migration. I have also cleared the config cache to make sure the connection variable is up-to-date.

When I test the implementation with the Queue Fake (https://laravel.com/docs/8.x/mocking#queue-fake), it tells me that nothing was queued.

Test code:

public function testJobQueuesMailable(): void
{
    Queue::fake();

    $this->job->handle();

    Queue::assertPushed(TestMailable::class, 1);
}

$this->job->handle() triggers the above code that loops over contacts and should queue the mailable.

I believe what I have matched the example in the documentation for queueing mailables by default (https://laravel.com/docs/8.x/mail#queueing-by-default), but it does not seem to be doing that. Any assistance or direction that can be provided would be appreciated.

Edit: Added code requested in comments by @chaudigv.

Feb
16
1 month ago
Activity icon

Awarded Best Reply on Date Casting In Query

I had tried this without success. I did find that use whereDate for the query did the trick though.

Activity icon

Replied to Date Casting In Query

I had tried this without success. I did find that use whereDate for the query did the trick though.

Activity icon

Started a new Conversation Date Casting In Query

I have a scope that applies to one of my models. It accepts a Carbon date instance that I am using to filter the results of the query. It is filtering on a date column, and when I pass the raw Carbon instance in to the where clause, it does not format the date correctly. I am expecting the format to be 'Y-m-d' and it is using 'Y-m-d H:m:s'. I have tried to cast the date field with the $casts property on my model, but it does not seem to have am impact for the query. Do casts work for queries?

Example code:

public function scopeWithMinDate(
    \Illuminate\Database\Eloquent\Builder $query,
    \Carbon\Carbon $date,
    string $operator = '='
): \Illuminate\Database\Eloquent\Builder
{
    return $query->where('min_date', $operator, $date);
}
Feb
03
2 months ago
Activity icon

Replied to Foreign Key Constraint '...' Are Incompatible

I recently ran into this problem during a migration to create a table with a foreign key constraint. I found that it had to due with the collation used on the table. Our DB schema is loaded with a schema file, and that has the table collation set to utf8mb4_0900_ai_ci. It looks like Laravel uses utf8mb4_unicode_ci by default.

I resolved the problem by setting the collation for the table during creation with $table->collation = 'YOUR_COLLATION_VALUE'