php - Laravel redirects all resources to the home -


in laravel 5.4 application have resource , controller. when enter url of resource action (like index) instead of getting controller function result(json), redirected /home: (i have logged in , redirected user's /home)

my controller:

class dreamcontroller extends controller {  public function __construct() {   $this->middleware('auth:api'); } public function index(request $request) {   $dreams = $request->user()->dreams()->orderby('created_at', 'desc');    return response()->json(['dreams' => $dreams]); } } 

my route api.php:

route::middleware('auth:api')->get('/user', function (request $request) {     return $request->user(); }); route::resource('dreams', 'dreamcontroller'); 

my web.php route:

route::get('/', function () {     return view('welcome'); }); route::resource('dreams', 'dreamcontroller'); auth::routes(); route::get('/home', 'homecontroller@index')->name('home');  

the application on local machine url is: http://127.0.0.1:8000/dreams redirected http://127.0.0.1:8000/home

try in web.php

route::get('/', function () {     return view('welcome'); }); auth::routes(); route::resource('dreams', 'dreamcontroller'); route::get('/home', 'homecontroller@index')->name('home');  

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -