![](/img/trans.png)
[英]Routes in laravel 5.2 are not automatically redirecting to login if not authenticated
[英]Routes Redirecting to the login page Laravel 5.2
我使用Entrust來驗證我的Laravel應用程序。 我不知道為什么,但我不能作為客人訪問我的公共路線。
這條路線適合客人:
Route::get('/course-calendar', function () {
$events = \App\Models\Event::all();
return view('public.calendar.index' , compact('events'));
});
但是當我使用這樣的路線時:
Route::resource('courses' , 'CourseController');
將我重定向到登錄頁面。 這兩條路線位於route.php
的頂部
這是我的控制器:
<?php namespace App\Http\Controllers;
use App\Models\Event; //models are at App\Models
class CourseController extends Controller
{
//Show lists of the events in the calendar
public function dekha()
{
$events = Event::all();
return view('public.calendar.index' , compact('events'));
}
//show single page
public function show($id)
{
$event = Event::find($id);
if (is_null($event))
{
return Redirect::route('courses');
}
return View::make('public.events.single', compact('event'));
}
}
這似乎很奇怪。 你能指出我錯過了什么嗎?
我在Controller.php
犯了一個愚蠢的錯誤。
我有這個:
public function __construct(){
$this->middleware('auth');
}
我不得不從controller.php
刪除代碼塊
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.