gvstavnev

gvstavnev

Member Since 1 Year Ago

Experience Points
4,030
Total
Experience

970 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
39
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
4,030 XP
Mar
09
7 months ago
Activity icon

Replied to Attach() On Custom BelongsToMany-Model

@burlresearch @staudenmeir — thank your for your replies. I appreciate it!

Activity icon

Replied to Attach() On Custom BelongsToMany-Model

@burlresearch Thanks for your reply. Do you gonna open a Issue on Github?

Mar
05
7 months ago
Activity icon

Started a new conversation Attach() On Custom BelongsToMany-Model

Hi there.

Im relatively new to laravel – so I hope my question is worth asking.

In my current project I have users and folders. A folder can have many users and a user can have many folders. So I came up with the belongsToMany relation. Then, I wanted a model that handles the relation between user and folder, because I want to assign different roles to it. So I created the a membership model.

I will only show you the relevant code (I hope). So this is my code:

User.php

    public function folders() {
        return $this
            ->belongsToMany(Folder::class)
            ->using(Membership::class);
    }

Folder.php

    public function users() {
        return $this
            ->belongsToMany(User::class)
            ->using(Membership::class);
    }

My question is now, how to attach a folder to a user. Currently, when Im trying to call $user->folders or $user->folders()->attach($folder) I get the error folder_user' doesn't exist – ye because I want the membership table to handle this.

Kind Regards Gustav

Feb
03
8 months ago
Activity icon

Replied to Cant Chain OrderBy And GroupBy

@TYKUS - Thank you for you reply. I tried this:

        return Auth::user()
            ->entries()
            ->get()
            ->groupBy(
                [   function($item) {
                        return $item->created_at->year;
                    },
                    function($item) {
                        return $item->created_at->month;
                    }
                ]
            )
            ->sortKeysDesc()
            ;

but get the same result. With the latest date at the bottom. Even tried sortKeys(), same result.

The only way i found, was to add ->values()->all() after ->sortKeysDesc(). Then its in the right order but the keys of the years get lost.

Whats going on here?

Side question: How to also order the months ?

Activity icon

Started a new conversation Cant Chain OrderBy And GroupBy

This is my Code:

    return Auth::user()
        ->entries()
        ->get()
        ->sortByDesc('created_at')->values()
        ->groupBy(
            [   function($item) {
                    return $item->created_at->year;
                },
                function($item) {
                    return $item->created_at->month;
                }
            ]
        )
        ;

Thats what i get:

{
    "1970": {
        "4": [
            {
                "id": 7,
                "user_id": 1,
                "name": "quo",
                "value": -2.14,
                "created_at": "1970-04-17 19:24:40",
                "updated_at": "2019-02-03 14:17:03"
            }
        ]
    },
    "1971": {
        "2": [
            {
                "id": 6,
                "user_id": 1,
                "name": "excepturi",
                "value": -8.78,
                "created_at": "1971-02-09 01:43:24",
                "updated_at": "2019-02-03 14:17:03"
            }
        ]
    },
    "1972": {
        "9": [
            {
                "id": 1,
                "user_id": 1,
                "name": "rerum",
                "value": -4.88,
                "created_at": "1972-09-19 13:57:22",
                "updated_at": "2019-02-03 14:17:03"
            }
        ]
    },
    "1977": {
        "11": [
            {
                "id": 3,
                "user_id": 1,
                "name": "totam",
                "value": -1.08,
                "created_at": "1977-11-15 06:37:35",
                "updated_at": "2019-02-03 14:17:03"
            }
        ]
    },
    "1979": {
        "9": [
            {
                "id": 5,
                "user_id": 1,
                "name": "ipsa",
                "value": -0.32999999999999996,
                "created_at": "1979-09-04 18:42:01",
                "updated_at": "2019-02-03 14:17:03"
            }
        ]
    },
    "1987": {
        "4": [
            {
                "id": 10,
                "user_id": 1,
                "name": "natus",
                "value": -8.18,
                "created_at": "1987-04-07 23:04:24",
                "updated_at": "2019-02-03 14:17:03"
            }
        ]
    },
    "1990": {
        "7": [
            {
                "id": 2,
                "user_id": 1,
                "name": "nobis",
                "value": -5.61,
                "created_at": "1990-07-02 00:16:35",
                "updated_at": "2019-02-03 14:17:03"
            }
        ]
    },
    "1995": {
        "4": [
            {
                "id": 4,
                "user_id": 1,
                "name": "expedita",
                "value": -0.35,
                "created_at": "1995-04-11 19:51:19",
                "updated_at": "2019-02-03 14:17:03"
            }
        ]
    },
    "1998": {
        "3": [
            {
                "id": 8,
                "user_id": 1,
                "name": "qui",
                "value": -3.04,
                "created_at": "1998-03-06 11:42:43",
                "updated_at": "2019-02-03 14:17:03"
            }
        ],
        "11": [
            {
                "id": 9,
                "user_id": 1,
                "name": "inventore",
                "value": -5.3100000000000005,
                "created_at": "1998-11-08 08:05:41",
                "updated_at": "2019-02-03 14:17:03"
            }
        ]
    }
}

But i want to get the latest at the top, and not at the bottom. When i tried to use orderBy instead of sortBy, like this:

return Auth::user()
            ->entries()
            ->orderBy('created_at')
            ->get()
            ->groupBy(
                [   function($item) {
                        return $item->created_at->year;
                    },
                    function($item) {
                        return $item->created_at->month;
                    }
                ]
            )
            ;

I get the same result, even with orderBy('created_at', 'desc'). Any Idea how to get 1998 at the top?

Thank you!