Laravel - Midlleware called after controller construct

I have trouble with checkauth controller that are called after SectionsController constructor - from this is extended ReportController and I don't know why it works like this. I try add middleware at the start of SectionController costruct like $this->middleware('checkauth'); but not working too.

Middleware

<?php

namespace App\Http\Middleware;

use Closure;
use Auth;


class CheckAuth
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (!Auth::check())
{
return redirect('/admin/login')->withErrors(['message' => 'You need to login before proceeding']);
}

return $next($request);
}
}

ReportController

<?php

namespace App\Http\Controllers\RMReport\Form;

use App\Http\Controllers\RMReport\SectionsController;
use Illuminate\Http\Request;
use Illuminate\Support\Str;


class ReportController extends SectionsController
{

public function __construct(){
/* dump("REPORT CONTROLLER:");
dump(\Auth::check());*/
parent::__construct();
}
.
.
.
}

SectionsController

<?php

namespace App\Http\Controllers\RMReport;

use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Support\Facades\View;
use App\Http\Controllers\Controller;
use Illuminate\Http\UploadedFile;



class SectionsController extends BaseController
{
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;

public function __construct(){
$this->middleware('checkauth');

dump("SECTIONSCONTROLLER: ");
dump(\Auth::check());
}
}

Output from route:list

GET|HEAD | admin/remote-report/{id?} | rm.report | App\Http\Controllers\RMReport\Form\ReportController@form | web,checkauth,checkownerRMreport |  
POST | admin/remote-report/{id?} | rm.report | App\Http\Controllers\RMReport\Form\ReportController@store | web,checkauth,checkownerRMreport |

Output on call GET

"SECTIONSCONTROLLER: "

false

"CHECKAUTH:"

true


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2zNxPA9
via IFTTT

تعليقات

المشاركات الشائعة من هذه المدونة

I am unable to figure out how to create payment collection request, after a form has been submitted in laravel

laravel, mysql transaction not working after failed one time