Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

DDSameera's avatar

Laravel Resources Vs Custom Controller Functions

I have BIG doubt . Hope someone help to clarify this .

I m really worry about the best practices of laravel 8 . Always I m trying to build up my application using laravel "resources". So Its very useful me to build up CRUD application .

Is that necessary or best practice to build up application using resource in controllers or Do i need to follow up my own custom functions in controller class

Please note : this is not Web Service. This is CRUD based Application.

Eg:

Custom Controller Functions and Routes

Route::group(['middleware' => ['auth']], function () {

    Route::get('subcat/loadall', [SubCategoryController::class, 'loadDataTableData']);
    Route::get('subcat/index', [SubCategoryController::class, 'index']);
    Route::post('subcat/create', [SubCategoryController::class, 'create']);
    Route::post('subcat/edit', [SubCategoryController::class, 'edit']);
    Route::post('subcat/update', [SubCategoryController::class, 'update']);
    Route::post('subcat/save', [SubCategoryController::class, 'save']);
    Route::post('subcat/delete', [SubCategoryController::class, 'delete']);

});

Resources Controller Function

Route::resource('maincat', MainCategoryController::class);

0 likes
2 replies
jlrdw's avatar

Do both as needed. I have in one an index method, but also an indexAdmin method.

Laravel is very flexible.

1 like
Niush's avatar
Niush
Best Answer
Level 50

It is a good practice to stick with resource, so that the url, route name, action and method follows general convention. https://laravel.com/docs/8.x/controllers#actions-handled-by-resource-controller

So, if you are working in a team, everyone can easily work and understand (Rather then having different route names and method to remember)

But, sometimes you might also want to use custom routes and there is nothing wrong about it.

2 likes

Please or to participate in this conversation.