Victori
Victori

Reputation: 359

New Class Instance or Everything in One - Laravel

I have an AdminControllerwhich loads all the views, although I will need to pass in information into that view.

Example Users Tab - View total users, new users, viewing the users profile etc, editing them.

Is it better to create a new controller to do those methods in and then in the AdminController to call $users = new UsersController; ?

I am trying to find the most efficient way OOP.

Upvotes: 1

Views: 155

Answers (1)

Brad
Brad

Reputation: 1899

Yes, you need to create a UsersController. It sounds like a resource controller would be your best option.

Do php artisan make:controller UsersController --resource and then add this to your routes file:

Route::resource('admin/users', 'UsersController')->middleware('auth');

Upvotes: 1

Related Questions