willjohnathan

willjohnathan

Member Since 2 Years Ago

Experience Points
38,920
Total
Experience

1,080 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
370
Lessons
Completed
Best Reply Awards
1
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.

Level 8
38,920 XP
May
19
1 week ago
Activity icon

Started a new Conversation Extend User Model (single Table) And Initiate From Auth()

I have a boolean on my user table to signify if they are a coder. I have a coder model that extends user as follows:

class Coder extends User
{

    protected $table = 'users';

    public static function boot()
    {
        parent::boot();

        static::addGlobalScope(function ($query) {
            $query->where('coder', true);
        });
    }

    public function passedTest()
    {
        return false;
    }
}

I suppose I could pass the user id in the route and just use route-model-binding to initiate the coder class, but if I just wanted to use the auth() method and not have to run an additional query, is there a clean way to do this

Currently have this, but this seems wrong to have the additional query when the auth()->user() is nearly the same thing:

    public function eligibility()
    {
        $coder = Coder::find(auth()->id());

	return view('coders.eligibility', compact('coder'));
}
Dec
27
5 months ago
Activity icon

Replied to Group Into Multiple Categories

@snapey but then wouldn't I not be able to group by renter.name since I loose all information about the video after the countBy() (my example probably breaks down a little, as that sounds odd, but assume a video belongs to a renter; maybe if i used purchaser instead of renter).

Edit: also it seems the countBy() just maps over the groupBy() thus only sending them to one category.

Activity icon

Replied to Group Into Multiple Categories

@nakov yes as really I am just grabbing the counts. So the total today, and this week. I am thinking I am going to save the result from the query into a variable and then do seperate groupby's for the overlaping categories. The front-end checks break down if I want to add "current month" and "last month" (not shown in my example) as then I have to do some complicated checks that I don't want in my view.

Yeah, i dont' think groupby can do it, but was curious if there was another collection method or a macro out there that could do it.

Activity icon

Replied to Group Into Multiple Categories

But I still need the today and yesterday groups. Basically I want to be able to view a snapshot of the rentals today, yesteday, this week, and last week.

Activity icon

Started a new Conversation Group Into Multiple Categories

I have a function that returns videos grouped by genre, then by creation_date (today, yesterday, this week, last week), then by the person that rented these videos. (Just a dummy problem to try to illustrate the problem). I would like for the groupby "date" part to group the "today" and "yesterday" items into the "this week" collection as well. Just curious if there is a simple way to do this without breaking this up or appending to a "parent" variable.

return Video::with('renter', 'genre')->latest()->get()->groupBy(
    [ 
        'genre.name',
        function ($video) {
            if ($video->created_at->isToday()) {
                    return 'Today';
            }

            if ($video->created_at->isYesterday()) {
                    return 'Yesterday';
            }

            if ($video->created_at->isCurrentWeek()) {
                    return 'This Week';
            }

            if ($record->created_at->isLastWeek()) {
                    return 'Last Week';
            }

            return 'older';
        },
        'renter.name'
    ]);