ehabafia

ehabafia

Member Since 5 Years Ago

Experience Points 61,050
Experience Level 13

3,950 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 766
Lessons
Completed
Best Reply Awards 0
Best Reply
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.

03 Jun
3 weeks ago

ehabafia left a reply on PHP Storm

I hope to see Jeffry reply to this post.

02 Jun
3 weeks ago

ehabafia left a reply on PHP Storm

Well, I agree, but Jeffrey Way does summarize and gives all the information on the documentation in a few videos that can make us master it in a much shorter time. So, please Jef considers updating or having a new series of videos to help us be more productive.

Thank you,

01 Jun
3 weeks ago

ehabafia started a new conversation PHP Storm

Hi Jef,

I know that you have a series of how to use PHP Storm, but it's extremely old. Can we have a new or updated series on the new PHP Storm with its all-new features?

Thank you,

19 Dec
6 months ago

ehabafia left a reply on A Nested Query

Thank you all, it works fine, but the only thing is that it will show you the categories that have products in it and the categories that are empty. I found another solution that will eliminate that, but not sure if it's the optimum way of doing it. Please advise.

public function scopeByUser(Builder $query, $user_id)
{
    return $query->whereHas('products', function ($q) use ($user_id) {
        $q->whereHas('users', function ($q) use ($user_id) {
            $q->where('id', $user_id);
        });
    });
}

public function scopeProductsByUser(Builder $query, $user_id)
{
    $query->with(['products'=> function ($q) use ($user_id) {
        $q->whereHas('users', function ($q) use ($user_id) {
            $q->where('id', $user_id);
        });
    }])->byUser($user_id);
}

They both stay in the Category model, and I call them as:

$categories = Category::productsByUser(auth()->id())->get();

This way I got only the categories that has products in it for that user.

18 Dec
6 months ago

ehabafia left a reply on A Nested Query

It's showing a byUser method not defined. so, it's not catching the scopeByUser where I have it in the Category Model for some reason. isn't it correct to have it there or it should be in the Product model or User model.

ehabafia left a reply on A Nested Query

Actually, What I am looking for is listing the Categories and along with each category the list of all the products that are related to that category for this user.

17 Dec
6 months ago

ehabafia started a new conversation A Nested Query

I have a Category / Products / Users I need to get all Categories of All Products for a specific user. I was able to make selecting a product for a specific User but I couldn't tell how to get all the categories of these products.

Products and Users relationship is ManyToMany. The relationship between product belongsTo Category and Category hasMany Products

Here is what I made:

$products = Product::byUser(auth()->id())->get();
{
    return $query->whereHas('users', function ($q) {
        $q->where('id', auth()->id());
    });
}

But I couldn't make it in a way to have:

$products = Category::productsByUser(auth()->id());

So that I can get all the categories and all the products of the loggedIn user.