Reputation: 183
I am trying to apply auth middleware to all routes except "editPostJob" route but it didnt work as there is an id in url(http://127.0.0.1:8000/editPostJob/1). Everytime i tried to go to that link it redirects me to login page.
in controller I tried:
public function __construct()
{
$this->middleware('auth')->except(['index', 'confirm','editPostJob']);
}
but it didnt work. Any idea what should i do ?
thanks for any help.
Upvotes: 0
Views: 634
Reputation: 183
I was able to solve it by doing:
public function __construct()
{
$this->middleware('auth')->except(['index', 'confirm', 'yourMethod']);
}
public function yourMethod(Request $request) //select statement
{
if (\Auth::check() == false) {
$is_read = "true";
} else {
$is_read = strip_tags($this->isLoggerOwnerOfPost($request->id));
}
$jobs = DB::table('jobs')->where('job_id', $request->id)->get();
return view('editPostJob', compact('jobs'))->with('is_read', $is_read);
}
Thanks Anurat !
Upvotes: 0