samedi 31 mars 2018

How can I implement Resource Controllers if I use many "get" on the laravel?

I have routes laravel like this :

Route::prefix('member')->middleware('auth')->group(function(){
    Route::prefix('purchase')->group(function(){
        Route::get('/', 'Member\PurchaseController@index')->name('member.purchase.index');
        Route::get('order', 'Member\PurchaseController@order')->name('member.purchase.order');
        Route::get('transaction', 'Member\PurchaseController@transaction')->name('member.purchase.transaction');
    });
});

My controller like this :

<?php
...
class PurchaseController extends Controller
{
    ...
    public function index()
    {
        ...
    }
    public function order()
    {
        ...
    }
    public function transaction()
    {
        ...
    }
}

I want to change it to Resource Controllers(https://laravel.com/docs/5.6/controllers#resource-controllers)

So I only use 1 routes

From my case, my routes to be like this :

Route::prefix('member')->middleware('auth')->group(function(){
    Route::resource('purchase', 'Member\PurchaseController');
});

If I using resouce controller, I only can data in the index method or show method

How can I get data in order method and transaction method?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2E9WOKj
via IFTTT

Aucun commentaire:

Enregistrer un commentaire