我剛剛安裝了laravel 5.2,並且我創建了auth註冊,登錄和重置密碼,但是現在我想創建一個我的項目的索引,其中所有用戶(也都未登錄)都可以訪問。我試圖創建Laravel 5.2 - 中間件認證
Route :: get('/',HomeController @ home');
但是這個視圖只對用戶登錄纔有效。
MY ROUTES
Route::auth();
Route::get('/home', '[email protected]');
// POST - FORM CREA
Route::get('/crea-regalo', '[email protected]');
Route::post('/crea-regalo', '[email protected]');
// LISTA ANNUNCI PRINCIPALE
Route::get('/', '[email protected]');
MY HOME控制器
class HomeController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}
/**
* Show the application dashboard.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$posts = Post::orderBy('id','DESC');
return view('home', compact('posts'));
}
public function home()
{
$posts = Post::all();
return view('index', compact('posts'));
}
}
如何創建視圖,所有用戶都可以訪問路線?
謝謝你的幫助!
yup!謝謝!我將創建另一個控制器,是最好的選擇! –