sjking85

sjking85

Member Since 1 Month Ago

Experience Points
230
Total
Experience

4,770 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
1
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
230 XP
Sep
26
3 weeks ago
Activity icon

Replied to Forbidden 403 When Trying To Create "show" Method

I wish you could also wind back the last 24 hours I've been trying to fix this...

THANK YOU!

Essentially, I have changed show to view in the UserPolicy.php and it is now working as expected. Thank you!

Activity icon

Started a new Conversation Forbidden 403 When Trying To Create "show" Method

I've obtained a pre-built script which includes a user management section.

I am trying to add to it a "Show" method, allowing me to click a "View" button next to the username and it will direct me to a show.blade.php with the user's details. The problem is, I keep hitting a brick wall by navigating to http://127.0.0.1:8000/dashboard/users/1 and it throwing a 403 Forbidden error.

My web.php route is as follows:

Route::group(['middleware' => 'auth'], function () {
    Route::resource('dashboard/users', 'UserController');
});

And my UserControlller.php looks like this:

public function show(User $user)
    {
        return view('users.show')->with('user', User::find($user));
    }

I also have a policy named UserPolicy.php which looks like this:

public function show(User $user)
    {
        return $user->isAdmin();
    }

In my UserRequest.php file, it checks to see if the user is authenticated:

public function authorize()
    {
        return auth()->check();
    }

I feel completely out of my depth. All other create, delete, edit functions work... just not the show function which I have added afterwards.

Sep
17
1 month ago
Activity icon

Replied to Passing Single Variable Across Multiple Controllers?

A good point well made, thank you.

Activity icon

Replied to Passing Single Variable Across Multiple Controllers?

Both... thank you very much. I have taken a look at the docs and simply added the details to the AppServiceProvider and it's working a charm.

Thank you both again, I appreciate it.

Activity icon

Started a new Conversation Passing Single Variable Across Multiple Controllers?

I'm sorry if it sounds like such a stupid question, I'm new to Laravel and I'm really enjoying the learning so far. I hope you can help with a query.

After much messing about, I have managed to display a simple count of the number of users in the User database.

I would like to do this on two views with different controllers, namely UserController and HomeController.

I have done so by simply having on my HomeController:

public function index()
    {
        $users = User::count();

        return view('dashboard', compact('users'));
    }

and in my blade file I have:

<span class="h2 font-weight-bold mb-0">{{ $users }}</span>

This shows up as expected.

The issue is I would like it also to be displayed on the view using the UserController, do I need to edit my index to show this too?

I have added the following to my pre-existing code:

public function index(User $model)
    {
        $users = User::count();

        return view('users.index', ['users' => $model->paginate(15)], compact('users'));
    }

...but it doesn't show the count.

Is there a way I can define it globally to then call on all pages? Any help for this rookie is appreciated.