2016-04-01 29 views
0

laravel uygulama geliştirmede yeni. authmiddleware kullanırken, kayıtsız kullanıcı için iyi çalışıyor (oturum açma sayfasına yönlendiriliyor). Ancak, , bu sayfayı ziyaret eden kullanıcı'u ziyaret ettiğinde, ana sayfaya yönlendirilir (kök dizin). routes.php kodundan rota altındaAuth ara katman yazılımı kullanıldığında, beni ana sayfasına yönlendiriliyorsunuz.

benim userController.php Kodun altında

Route::group(['middleware' => 'auth'], function() { 
    Route::resource('/edit', '[email protected]'); 
}); 

benim authController Kodun altında

<?php 
namespace App\Http\Controllers; 
use Illuminate\Http\Request; 
use App\Http\Requests; 
use App\allUsers; 
class userController extends Controller 
{ 
    public function index(){ 
    } 

    public function show($id){ 
    } 

    public function edit(){ 
     return view('auth.user_edit'); 
    } 
    } 

<?php 

namespace App\Http\Controllers\Auth; 

use App\User; 
use Validator; 
use App\Http\Controllers\Controller; 
use Illuminate\Foundation\Auth\ThrottlesLogins; 
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers; 

class AuthController extends Controller 
{ 
/* 
    |-------------------------------------------------------------------------- 
| Registration & Login Controller 
|-------------------------------------------------------------------------- 
| 
| This controller handles the registration of new users, as well as the 
| authentication of existing users. By default, this controller uses 
| a simple trait to add these behaviors. Why don't you explore it? 
| 
*/ 

use AuthenticatesAndRegistersUsers, ThrottlesLogins; 

/** 
* Where to redirect users after login/registration. 
* 
* @var string 
*/ 
protected $redirectTo = '/dashboard'; 

/** 
* Create a new authentication controller instance. 
* 
* @return void 
*/ 
public function __construct() 
{ 
    $this->middleware($this->guestMiddleware(), ['except' => 'logout']); 
} 

/** 
* Get a validator for an incoming registration request. 
* 
* @param array $data 
* @return \Illuminate\Contracts\Validation\Validator 
*/ 
protected function validator(array $data) 
{ 
    return Validator::make($data, [ 
     'name' => 'required|max:255', 
     'email' => 'required|email|max:255|unique:users', 
     'password' => 'required|min:6|confirmed', 
    ]); 
} 

/** 
* Create a new user instance after a valid registration. 
* 
* @param array $data 
* @return User 
*/ 
protected function create(array $data) 
{ 
    return User::create([ 
     'name' => $data['name'], 
     'email' => $data['email'], 
     'password' => bcrypt($data['password']), 
    ]); 
} 
} 

Herkes bana yardımcı olmasıdır lütfen .

cevap

0

Sen AuthController içinde $ redirectTo değişkeni üzerine yazabilirsiniz:

/** 
* Where to redirect users after login/registration. 
* 
* @var string 
*/ 
protected $redirectTo = '/dashboard'; 

Güncelleme:

Route::group(['middleware' => 'auth'], function() { 
    Route::get('edit', '[email protected]'); 
}); 

Rota :: kaynak tüm CRUD yolları oluşturur:

rotanızı değiştirmek deneyin otomatik olarak.

https://laravel.com/docs/5.1/controllers#restful-resource-controllers

+0

Güzergahı değiştiriniz. –

+0

Auth Denetleyicinizi –

+0

numaralı soruya gönderebilir misiniz? Şimdi kontrol edin. Güncellenmiş!! –

0

Evet Sorun çözüldü. Sadece yol

Route::group(['middleware' => ['web', 'auth']], function() { 
    Route::get('/edit', '[email protected]'); 
}); 
İlgili konular