hamza

hamza

Member Since 2 Years Ago

Experience Points 1,650
Experience Level 1

3,350 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 14
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.

11 Jul
1 week ago

hamza left a reply on Get Full Key From Multidimensional Array

Thanks for a wonderful answer.

10 Jul
1 week ago

hamza started a new conversation Get Full Key From Multidimensional Array

Let's say I have this array:

[
    'a' => [
        'b' => [
            'c' => 1,
            'd' => 2,
        ],
        'e' => [
            'f' => 3,
            'g' => 4
        ],
        'h' => [
            'i' => [
                'j' => 5
            ],
        ],
        'j' => [
            'k' => 2
        ]
    ]
];

What I want is a PHP function that accepts this array as well as a key. Let's say the key is 'j'. Then it should return an array that contains the full key to access all 'j' keys in the array.

For this array, it should return

[
    'a.j',
    'a.h.i.j'
];

In this way, I will be able to access the values of the array using this full key and edit its value. But I want to search using a single key that could be anywhere in the array.

I know it will be done using the recursive technique but I could not do it.

Any help will be appreciated. Thanks.

28 Feb
4 months ago

hamza left a reply on Package Development: Remove Published Views When Package Is Removed

@BOBBYBOUWMANN - I am using windows. So, when I would remove the package in windows it does not work. Will it work on Linux only. Also, I am going to add this to the package composer.json and every user who installs my package will have the functionality?

hamza started a new conversation Package Development: Remove Published Views When Package Is Removed

Really stuck on this problem.

Basically I have built a Laravel Package that has some views that can be published. Now, what I want is that when a user installs the package and publishes its assets and then when the user uninstalls the package either by running composer remove package or removing the entry from the package.json file and running composer update, it should remove the published views as well.

I think that I can make some changes in the package composer.json file but its not working. I think composer scripts are the solution but right now can't implement them.

Looking forward for help.

Thanks.

05 Feb
5 months ago

hamza left a reply on Policy Not Working. Always Return False

Thanks everyone for help. I found the solution. I was using Vanguard Laravel Package and in that package, they removed $this->registerPolicies(); from the boot. Thanks.

hamza left a reply on Policy Not Working. Always Return False

@MUSA11971 - You are right. Policy is not even getting called. But I do not why its not getting called.

hamza left a reply on Policy Not Working. Always Return False

@MUNAZZIL - I do not understand what you are saying. Can you please explain?

hamza started a new conversation Policy Not Working. Always Return False

I am new to using Policies in Laravel. I am using Policy for the PostController so that only the user with the appropriate permission can edit and update the post. But it always returns false.

Here is PostController edit method

public function edit(Post $post)
{
    $this->authorize('edit', $post);

    $post = $post->load(['categories', 'user']);

    $categories = Category::all();

    return view('post.edit', compact('post', 'categories'));
}

here is my Post Policy Class edit method

public function edit(User $user, Post $post)
{
    $role = $user->role->name;

    if ($role == 'Admin' || $role == 'Editor') {
        return true;
    }

    return $user->id == $post->user_id;
}

I tried to return true in the Edit Method of the PostPolicy but it still do not work.

I have added the following to the AuthServiceProvider

protected $policies = [
    'Vanguard\Model' => 'Vanguard\Policies\ModelPolicy',
    Post::class => PostPolicy::class,
];

Also Auth middleware is already added. Please I need urgent help

08 Apr
2 years ago

hamza started a new conversation How To Get All Users Who Liked An Image

Hi, I am creating a photo gallery system where one user could like many images. An image could also be liked many user. How to get all users who liked an image using Eloquent. I have written this code in Photo.php Model

    public function likes()
    {
        return $this->belongsToMany('App\User', 'likes', 'user_id', 'photo_id');
    }

In my User table I have created these relationships

   //All Photos user liked
    public function likes()
    {
        return $this->belongsToMany('App\Photo', 'likes', 'photo_id', 'user_id');
    }

// Like an image
    public function like(Photo $photo)
    {
        $this->likes()->attach($photo->id);
    }
// Remove the like from the image
    public function dislike(Photo $photo)
    {
        $this->likes()->detach($photo->id);
    }
// Does this user likes an image.
    public function isLiking(Photo $photo)
    {
        return $this->likes->contains($photo);
    }

All Relationships in user model works fine but Photo model returns 0.