我试图从中间件调用一个视图,但是我收到了这个错误:
调用未定义的方法Illuminate \ Http \ Response :: with()
中间件
<?php
namespace App\Http\Middleware;
use Closure;
use App\Models\Readdb;
class Adminlogin {
public function handle($request, Closure $next) {
if (!$request->session()->has('userid')) {
$db = new Readdb();
$admin_theme = $db::get_setting('admin_theme');
$data = array(
'title' => 'My App yo',
'Description' => 'This is New Application',
'author' => 'foo'
);
return response()->view('admin.auth.login')->with($data);
} else {
return response()->view('admin.dash');
}
return $next($request);
}
}
查看文件
{{Session::get('name')}}
答案 0 :(得分:1)
您不应将with()
与response()
一起使用,请执行以下操作:
return view('admin.auth.login')->with($data);
希望这有帮助!