cabeeb

cabeeb

Richardson, TX

Member Since 2 Years Ago

Experience Points 22,340
Experience
Level
Lessons Completed 219
Lessons
Completed
Best Reply Awards 0
Best Answer
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    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 Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

27 May
7 months ago

cabeeb left a reply on Best Practices To Avoid Eager Loading Multiple Times

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

cabeeb 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?

20 Apr
9 months ago

cabeeb left a reply on 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.

cabeeb 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 == Actions::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 Actions::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 have the same created_at?

29 Jan
11 months ago

cabeeb left a reply on Method Argument Of Multiple Types

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

cabeeb 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)

16 Jan
1 year ago

cabeeb started a new conversation Flipping Model->Relationship Order

I'm building an app with players that can be invited to games (as well as other things). 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.

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

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

The best I can come up with is to do $game->load('invites.players') but that gives me something like this:

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, but it feels really gross:

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

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

Any advice?

23 Aug
1 year ago

cabeeb 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!

10 Dec
2 years ago

cabeeb left a reply on 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?

cabeeb 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!