CodebyRay

CodebyRay

Freelance Web Developer at CodebyRay (Myself)

Member Since 2 Years Ago

Experience Points
12,070
Total
Experience

2,930 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
36
Lessons
Completed
Best Reply Awards
10
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 3
12,070 XP
Feb
06
2 weeks ago
Activity icon

Awarded Best Reply on Faker Conditional Value

Just a thought haven't tested it but couldn't you use Carbon to generate the next_pay_date assign it to a variable then create the second_next_pay_date based on that value and assign to a variable at the top of the faker model and use those variables in the in the return block?

$factory->define(App\Employer::class, function (Faker\Generator $faker) {

    $frequency = $items[array_rand('weekly', 'bi-weekly', 'monthly')];

    if($frequency == 'weekly') {
        // Create the logic here for the dates
        $dt = Carbon::tomorrow();

        $next_pay = $dt;
        $pay_next = $dt->addWeek();
    }

    return [
        'pay_frequency' => $frequency,
        'next_pay_date' => $next_pay,
        'second_next_pay_date' => $pay_next,
    ];
});

Then use the variables created in the factory model.

Jan
22
1 month ago
Activity icon

Replied to How To Passing $_FILES Value As Request Directly In Controller Function Using App()?

@nikunj001 Is the file being uploaded via form? If so you need to let your controller know to accept files by adding it to your form tag:

<form method="post" enctype="multipart/form-data">

Then you can access it as @skauk stated above. If you need other help you'll need to show us your controller method and other code associated with what you're doing. Not enough info to give you solid feedback.

Hope this helps.

Activity icon

Replied to How To Passing $_FILES Value As Request Directly In Controller Function Using App()?

Do you have this in your form tag:

enctype="multipart/form-data"

You will not get the files if that is not in your form tag.

Hope this helps.

Regards, Ray

Activity icon

Replied to Delete Model With All Relations

When setting up your migration and creating a foreign key you can set the onDelete to cascade and this will delete the comments and reviews when the post has been deleted if I am not mistaken.

Such as:

$table->foreign('post_id')->references('id')->on('posts')->onDelete('cascade');

You would add this to the comments and reviews migration. This is assuming you have 'post_id' as a column in both tables.

Hope this helps.

Regards, Ray

Dec
05
2 months ago
Activity icon

Replied to GroupBy Not Working In Closure.

Thank you. Ill check it out.

Activity icon

Started a new Conversation GroupBy Not Working In Closure.

Hello,

I have searched and have not found an answer to this problem I am having. I have either looked at this too long and just cannot figure it out or it's so simple I am just over thinking it.

Here is the query I have, it returns all the results, however it does not group the results.

$ratings = $this->whereHasMorph('reviewrateable', '*', function (Builder $query) {
                return $query->groupBy('reviewrateable_id')
                ->havingRaw('AVG(rating) >= 3');
                    })->where('approved', true)
                ->orderBy('rating', 'desc')->get();

Table setup

id  rating  approved    reviewrateable_type reviewrateable_id   author_type author_id
1   3   1   App\User    1   App\User    1
2   3   1   App\User    1   App\User    1
3   3   1   App\User    2   App\User    1
4   5   1   App\Dealer  52  App\User    1
5   3   1   App\Dealer  10  App\User    1
6   2   1   App\Dealer  125 App\User    1

When I run the query I get everything in the table with a rating of 3 or higher. However, the first 2 both have a rating of 3 and the same reviewrateable_id and should be returned as 1. Not sure if I am trying to get the average wrong or not.

Thank you in advance for your help.

Regards,

Ray