cabeeb

cabeeb

Member Since 2 Years Ago

Richardson, TX

Experience Points
22,940
Total
Experience

2,060 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
225
Lessons
Completed
Best Reply Awards
0
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 5
22,940 XP
May
27
1 year ago
Activity icon

Replied to Best Practices To Avoid Eager Loading Multiple Times

Oh wow, yeah that's very handy. Not sure how I've missed that. Thanks!

Activity icon

Started a new Conversation Best Practices To Avoid Eager Loading Multiple Times

I have a dedicated service class for each of my primary models (eg UserServices for Users, etc). Several of the functions in these classes are called by other functions within the same class, and different functions need access to different relationships for the User. For instance, a function that checks a User's Friends might also call a function that checks a User's Activity history.

All that to say, I've been trying to figure out how best to load relationships only when I need them, and to not constantly be reloading the relationships. Should I just put a if (relationLoaded(...)) check at the beginning of each of these functions?

Apr
20
1 year ago
Activity icon

Replied to Get Latest Item When Several Have The Same Created_at

Great, thanks everyone! I'm going to do latest('id') since the ids are auto-incrementing anyways.

Activity icon

Started a new Conversation Get Latest Item When Several Have The Same Created_at

I'm using TDD on a project as I work through some Undo functionality. I only want the user to be able to undo the latest action that they have taken, so I'm doing a check to make sure that the id of the action being undone is the most recent database entry. Something like $undoAction->id == Action::latest()->first()->id

When I run it on real-world data, it works great, but I'm having trouble during testing. Since phpunit creates all of the actions in miliseconds (via factories), they all have the same created_at value, and the query is actually returning the first action, not the last.

I was able to make it work with Action::latest('created_at')->latest('id')->first() which I assume is sorting by created_at and then id, but it feels gross.

Is there a better way to get the latest Action row when they all have the same created_at value?

Jan
29
1 year ago
Activity icon

Replied to Method Argument Of Multiple Types

@martinbean Thanks! So, in that case just do some gettype() checks at the beginning of the method to figure out what we're dealing with?

Activity icon

Started a new Conversation Method Argument Of Multiple Types

I have a Service with several methods used throughout my application to invite players to a game. I would like to have a single method that can invite one or many players.

What is the best practice for setting up a method that can accept a single model or collection of models (or array of model ids, for that matter)

Or should it be multiple methods that are specific to the arguments (eg invitePlayer, invitePlayers, invitePlayersById)

Jan
16
1 year ago
Activity icon

Started a new Conversation Flipping Model->Relationship Order

I'm building an app with Players that can be invited to Games. Players can also be invited to other things, so I created a polymorphic Invite model to store the invite response, time, etc.

//Invite.php
public function player()
{
    return $this->belongsTo('App\Player');
}

public function invitable()
{
    return $this->morphTo();
}

I need to be able to get all of the players that have been invited to a particular game, as well as their invite status. The best I can come up with is to do $game->load('invites.players') which gives me:

App\Invite {
    id: 1,
    ...
    player: App\Player {
        ...
    }
}

But I'd really like for the Player to be the top-level model, with an invite attribute, almost like a pivot. I was able to do it with this mess, but it feels really gross:

$game->load('invites.player');

$invitedPlayers = $game->invites->map(function($invite){
    $obj = $invite->player;
    
    unset($invite->player);
    $obj->invite = $invite;
    
    return $obj;
});

Any advice?

Aug
23
2 years ago
Activity icon

Started a new Conversation Trigger Audio File From Vuex

I have a Vue/Vuex app that needs to play UI sounds (blips, beeps) at various points, generally triggered by Pusher/Echo. I'd like to store all of the audio in a separate component, and have the Vuex store be able to trigger an event in that Audio component. There's not any persistent data, per se, so storing something in the Vuex store doesn't quite feel right.

That being said, the best idea I can come up with is to have an audioQueue array in my store and have the Audio component watch for changes. On change, the component triggers play() on the queued audio file and remove it from the queue via a Vuex commit. But any other suggestions would be very appreciated!

Dec
10
2 years ago
Activity icon

Replied to Database Naming Conventions

Great, thanks @craigpaul! And I'm assuming it won't cause an issue with having Models and objects named "Table" and "Group"? Is there some kind of convention or best practice for naming groups of objects like that?

Activity icon

Started a new Conversation Database Naming Conventions

FIRST POST!

Ok, I'm building an application in Laravel that includes people, and seating for these people broken up into tables (eg 20 people split up across seats at 3 dinner tables). It also includes a way to arbitrarily group people for organizational purposes (eg create a a group of just the founding members).

My initial thought was to name those two models Tables and Groups respectively. But I'm afraid of potential SQL conflicts with those specific words. Is there a standard for naming arbitrary groupings like that? Peoplegroup or Seatgroup or something like that? Or will Tables and Groups be ok? Thanks!