lundi 26 juin 2017

Custom Method Declaration in Laravel 5

i am unable to access newly created custom method in URL. I am using laravel 5. Everything works fine, if i use default method index(), but when i create a custom method, i get error. Following is my method in controller.

namespace App\Modules\Admin\Controllers;

use App\Modules\Admin\Models\Store;
use App\Modules\Core\Controllers\ActionController;


class StoreController extends ActionController
{   
   public function storeDetails()
   {
        return "1"; 
   }
}

and below is my code in routes

   Route::group(['prefix' => 'admins'], function() {


        Route::group(['prefix' => 'store'], function() {


            Route::get('details', '\App\Modules\Admin\Controllers\StoreController@storeDetails')
            ->name('api.admins.store.storeDetails');

        });

            Route::resource('store', 'App\Modules\Admin\Controllers\StoreController',
                    [
                            'only' => ['index']
                    ]
            );

    });

And when ever i try to access "http://localhost/api/admins/store/details", i am getting error "You dont have access to this resource". I am using swagger to test the API. I ran the seed permission command, but still i get same 403 issue. Can anyone tell me how should i get custom URL working.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire