apokall

apokall

Member Since 1 Year Ago

Dnepr

Experience Points
260
Total
Experience

4,740 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
0
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 1
260 XP
Feb
08
2 weeks ago
Activity icon

Replied to Dont Get Relation If Add OrderBy And Take\Limit

    /**
     * Relation with player games
     *
     * @return HasMany
     */
    public function playerGames()
    {
        return $this->hasMany(PlayerGame::class);
    }

Everything is good, because I wrote that if you comment out these two lines, then with loads playerGames well, this is not the problem :( The problem is that if I add `$ query-> select (['id', 'winner']);` or `$ query-> orderBy ('created_at', 'desc');` `only then stops loading my PlayerGames

Feb
07
2 weeks ago
Activity icon

Replied to Dont Get Relation If Add OrderBy And Take\Limit

    +grammar: Illuminate\Database\Query\Grammars\MySqlGrammar {#233}
    +processor: Illuminate\Database\Query\Processors\MySqlProcessor {#234}
    +bindings: array:7 [
      "select" => []
      "from" => []
      "join" => []
      "where" => array:2 [
        0 => 1
        1 => 8
      ]
      "having" => []
      "order" => []
      "union" => []
    ]
    +aggregate: null
    +columns: null
    +distinct: false
    +from: "users"
    +joins: null
    +wheres: array:1 [
      0 => array:4 [
        "type" => "In"
        "column" => "id"
        "values" => array:2 [
          0 => 1
          1 => 8
        ]
        "boolean" => "and"
      ]
    ]
    +groups: null
    +havings: null
    +orders: null
    +limit: null
    +offset: null
    +unions: null
    +unionLimit: null
    +unionOffset: null
    +unionOrders: null
    +lock: null
    +operators: array:29 [
      0 => "="
      1 => "<"
      2 => ">"
      3 => "<="
      4 => ">="
      5 => "<>"
      6 => "!="
      7 => "<=>"
      8 => "like"
      9 => "like binary"
      10 => "not like"
      11 => "ilike"
      12 => "&"
      13 => "|"
      14 => "^"
      15 => "<<"
      16 => ">>"
      17 => "rlike"
      18 => "regexp"
      19 => "not regexp"
      20 => "~"
      21 => "~*"
      22 => "!~"
      23 => "!~*"
      24 => "similar to"
      25 => "not similar to"
      26 => "not ilike"
      27 => "~~*"
      28 => "!~~*"
    ]
    +useWritePdo: false
  }
  #model: App\Models\User {#816
    #connection: "mysql"
    #appends: array:1 [
      0 => "lvl"
    ]
    #guard_name: "web"
    #fillable: array:22 [
      0 => "name"
      1 => "email"
      2 => "password"
      3 => "email_verified"
      4 => "verified_token"
      5 => "country_id"
      6 => "gender"
      7 => "avatar"
      8 => "phone"
      9 => "last_ip"
      10 => "last_login"
      11 => "is_online"
      12 => "is_banned"
      13 => "ban_expires_at"
      14 => "last_bonus_at"
      15 => "birthday_at"
      16 => "secret_2fa"
      17 => "temp_token"
      18 => "soft"
      19 => "hard"
      20 => "intelligence"
      21 => "token_forgot_password"
    ]
    #dates: array:3 [
      0 => "birthday_at"
      1 => "last_bonus_at"
      2 => "ban_expires_at"
    ]
    #hidden: array:2 [
      0 => "password"
      1 => "remember_token"
    ]
    -currency: array:2 [
      1 => "soft"
      2 => "hard"
    ]
    #table: null
    #primaryKey: "id"
    #keyType: "int"
    +incrementing: true
    #with: []
    #withCount: []
    #perPage: 15
    +exists: false
    +wasRecentlyCreated: false
    #attributes: []
    #original: []
    #changes: []
    #casts: []
    #dateFormat: null
    #dispatchesEvents: []
    #observables: []
    #relations: []
    #touches: []
    +timestamps: true
    #visible: []
    #guarded: array:1 [
      0 => "*"
    ]
    #rememberTokenName: "remember_token"
    #accessToken: null
    -roleClass: null
    -permissionClass: null
  }
  #eagerLoad: array:1 [
    "playerGames" => Closure($query) {#1017
      class: "App\Jobs\SomeJobJob"
      this: App\Jobs\SomeJobJob {#794 …}
      file: "/var/www/someProject/app/Jobs/SomeJobJob.php"
      line: "124 to 131"
    }
  ]
  #localMacros: []
  #onDelete: null
  #passthru: array:13 [
    0 => "insert"
    1 => "insertGetId"
    2 => "getBindings"
    3 => "toSql"
    4 => "exists"
    5 => "doesntExist"
    6 => "count"
    7 => "min"
    8 => "max"
    9 => "avg"
    10 => "average"
    11 => "sum"
    12 => "getConnection"
  ]
  #scopes: []
  #removedScopes: []
}
Activity icon

Replied to Dont Get Relation If Add OrderBy And Take\Limit

I updated my code and correct answer

Activity icon

Started a new Conversation Dont Get Relation If Add OrderBy And Take\Limit

User::with(['playerGames' => function($query) {
            $query->whereDate('created_at', now());
            $query->where('status', PlayerGame::PLAYER_GAME_STATUS_FINISHED);
//          $query->select(['id', 'winner']);
//          $query->orderBy('created_at', 'desc');
            $query->take(21);
        }])->get()

All hello! I have some problems and two questions:

  1. Why i dont get any relation records in my user model if i uncomment "$query->orderBy('created_at', 'desc');"
  2. Why i dont get any relation records in my user model if i uncomment "$query->select(['id', 'winner'])"

I tried different combinations already, but they do not help me. If I remove take \ limit but leave ordeBy\ lastest then records will appear in my user model. Please help anyone who encountered a similar problem when loading Eager.