k娱乐百家乐-四川省2019年扩招

首页

AD联系:507867812

k娱乐百家乐

时间:2019-11-12 07:37:53 作者:2018注册送68 浏览量:96794

k娱乐百家乐Laravel框架实现利用中间件进行操作日志记录功能Laravel框架实现利用中间件进行操作日志记录功能Laravel框架实现利用中间件进行操作日志记录功能Laravel框架实现利用中间件进行操作日志记录功能Laravel框架实现利用中间件进行操作日志记录功能

本文实例讲述了Laravel框架实现利用中间件进行操作日志记录功能。分享给大家供大家参考,具体如下:

利用中间件进行操作日志记录过程:

1、创建中间件

php artisan make:middleware AdminOperationLog

2、生成了文件./app/Http/Middleware/AdminOperationLog.php

代码如下:

<?phpnamespace App\Http\Middleware;use Closure;use Illuminate\Http\Request;use Illuminate\Support\Facades\Auth;use App\Http\Models\OperationLog;class AdminOperationLog{ /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user_id = 0; if(Auth::check()) { $user_id = (int) Auth::id(); } $_SERVER['admin_uid'] = $user_id; if('GET' != $request->method()){ $input = $request->all(); $log = new OperationLog(); # 提前创建表、model $log->uid = $user_id; $log->path = $request->path(); $log->method = $request->method(); $log->ip = $request->ip(); $log->sql = ''; $log->input = json_encode($input, JSON_UNESCAPED_UNICODE); $log->save(); # 记录日志 } return $next($request); }}

3、中间件引入 ./app/Http/Kernel.php

protected $middlewareGroups = [ 'web' => [ ... \App\Http\Middleware\AdminOperationLog::class, ... ], 'api' => [ 'throttle:60,1', 'bindings', ], ];

此时进行操作时就会记录操作日志

更多关于Laravel相关内容感兴趣的读者可查看本站专题:《Laravel框架入门与进阶教程》、《php优秀开发框架总结》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Laravel框架的PHP程序设计有所帮助。

Laravel框架实现利用中间件进行操作日志记录功能,见下图

Laravel框架实现利用中间件进行操作日志记录功能

本文实例讲述了Laravel框架实现利用中间件进行操作日志记录功能。分享给大家供大家参考,具体如下:

利用中间件进行操作日志记录过程:

1、创建中间件

php artisan make:middleware AdminOperationLog

2、生成了文件./app/Http/Middleware/AdminOperationLog.php

代码如下:

<?phpnamespace App\Http\Middleware;use Closure;use Illuminate\Http\Request;use Illuminate\Support\Facades\Auth;use App\Http\Models\OperationLog;class AdminOperationLog{ /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user_id = 0; if(Auth::check()) { $user_id = (int) Auth::id(); } $_SERVER['admin_uid'] = $user_id; if('GET' != $request->method()){ $input = $request->all(); $log = new OperationLog(); # 提前创建表、model $log->uid = $user_id; $log->path = $request->path(); $log->method = $request->method(); $log->ip = $request->ip(); $log->sql = ''; $log->input = json_encode($input, JSON_UNESCAPED_UNICODE); $log->save(); # 记录日志 } return $next($request); }}

3、中间件引入 ./app/Http/Kernel.php

protected $middlewareGroups = [ 'web' => [ ... \App\Http\Middleware\AdminOperationLog::class, ... ], 'api' => [ 'throttle:60,1', 'bindings', ], ];

此时进行操作时就会记录操作日志

更多关于Laravel相关内容感兴趣的读者可查看本站专题:《Laravel框架入门与进阶教程》、《php优秀开发框架总结》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Laravel框架的PHP程序设计有所帮助。

Laravel框架实现利用中间件进行操作日志记录功能,见下图

本文实例讲述了Laravel框架实现利用中间件进行操作日志记录功能。分享给大家供大家参考,具体如下:

利用中间件进行操作日志记录过程:

1、创建中间件

php artisan make:middleware AdminOperationLog

2、生成了文件./app/Http/Middleware/AdminOperationLog.php

代码如下:

<?phpnamespace App\Http\Middleware;use Closure;use Illuminate\Http\Request;use Illuminate\Support\Facades\Auth;use App\Http\Models\OperationLog;class AdminOperationLog{ /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user_id = 0; if(Auth::check()) { $user_id = (int) Auth::id(); } $_SERVER['admin_uid'] = $user_id; if('GET' != $request->method()){ $input = $request->all(); $log = new OperationLog(); # 提前创建表、model $log->uid = $user_id; $log->path = $request->path(); $log->method = $request->method(); $log->ip = $request->ip(); $log->sql = ''; $log->input = json_encode($input, JSON_UNESCAPED_UNICODE); $log->save(); # 记录日志 } return $next($request); }}

3、中间件引入 ./app/Http/Kernel.php

protected $middlewareGroups = [ 'web' => [ ... \App\Http\Middleware\AdminOperationLog::class, ... ], 'api' => [ 'throttle:60,1', 'bindings', ], ];

此时进行操作时就会记录操作日志

更多关于Laravel相关内容感兴趣的读者可查看本站专题:《Laravel框架入门与进阶教程》、《php优秀开发框架总结》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Laravel框架的PHP程序设计有所帮助。

Laravel框架实现利用中间件进行操作日志记录功能

本文实例讲述了Laravel框架实现利用中间件进行操作日志记录功能。分享给大家供大家参考,具体如下:

利用中间件进行操作日志记录过程:

1、创建中间件

php artisan make:middleware AdminOperationLog

2、生成了文件./app/Http/Middleware/AdminOperationLog.php

代码如下:

<?phpnamespace App\Http\Middleware;use Closure;use Illuminate\Http\Request;use Illuminate\Support\Facades\Auth;use App\Http\Models\OperationLog;class AdminOperationLog{ /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user_id = 0; if(Auth::check()) { $user_id = (int) Auth::id(); } $_SERVER['admin_uid'] = $user_id; if('GET' != $request->method()){ $input = $request->all(); $log = new OperationLog(); # 提前创建表、model $log->uid = $user_id; $log->path = $request->path(); $log->method = $request->method(); $log->ip = $request->ip(); $log->sql = ''; $log->input = json_encode($input, JSON_UNESCAPED_UNICODE); $log->save(); # 记录日志 } return $next($request); }}

3、中间件引入 ./app/Http/Kernel.php

protected $middlewareGroups = [ 'web' => [ ... \App\Http\Middleware\AdminOperationLog::class, ... ], 'api' => [ 'throttle:60,1', 'bindings', ], ];

此时进行操作时就会记录操作日志

更多关于Laravel相关内容感兴趣的读者可查看本站专题:《Laravel框架入门与进阶教程》、《php优秀开发框架总结》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Laravel框架的PHP程序设计有所帮助。

Laravel框架实现利用中间件进行操作日志记录功能,如下图

本文实例讲述了Laravel框架实现利用中间件进行操作日志记录功能。分享给大家供大家参考,具体如下:

利用中间件进行操作日志记录过程:

1、创建中间件

php artisan make:middleware AdminOperationLog

2、生成了文件./app/Http/Middleware/AdminOperationLog.php

代码如下:

<?phpnamespace App\Http\Middleware;use Closure;use Illuminate\Http\Request;use Illuminate\Support\Facades\Auth;use App\Http\Models\OperationLog;class AdminOperationLog{ /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user_id = 0; if(Auth::check()) { $user_id = (int) Auth::id(); } $_SERVER['admin_uid'] = $user_id; if('GET' != $request->method()){ $input = $request->all(); $log = new OperationLog(); # 提前创建表、model $log->uid = $user_id; $log->path = $request->path(); $log->method = $request->method(); $log->ip = $request->ip(); $log->sql = ''; $log->input = json_encode($input, JSON_UNESCAPED_UNICODE); $log->save(); # 记录日志 } return $next($request); }}

3、中间件引入 ./app/Http/Kernel.php

protected $middlewareGroups = [ 'web' => [ ... \App\Http\Middleware\AdminOperationLog::class, ... ], 'api' => [ 'throttle:60,1', 'bindings', ], ];

此时进行操作时就会记录操作日志

更多关于Laravel相关内容感兴趣的读者可查看本站专题:《Laravel框架入门与进阶教程》、《php优秀开发框架总结》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Laravel框架的PHP程序设计有所帮助。

Laravel框架实现利用中间件进行操作日志记录功能

Laravel框架实现利用中间件进行操作日志记录功能

如下图

本文实例讲述了Laravel框架实现利用中间件进行操作日志记录功能。分享给大家供大家参考,具体如下:

利用中间件进行操作日志记录过程:

1、创建中间件

php artisan make:middleware AdminOperationLog

2、生成了文件./app/Http/Middleware/AdminOperationLog.php

代码如下:

<?phpnamespace App\Http\Middleware;use Closure;use Illuminate\Http\Request;use Illuminate\Support\Facades\Auth;use App\Http\Models\OperationLog;class AdminOperationLog{ /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user_id = 0; if(Auth::check()) { $user_id = (int) Auth::id(); } $_SERVER['admin_uid'] = $user_id; if('GET' != $request->method()){ $input = $request->all(); $log = new OperationLog(); # 提前创建表、model $log->uid = $user_id; $log->path = $request->path(); $log->method = $request->method(); $log->ip = $request->ip(); $log->sql = ''; $log->input = json_encode($input, JSON_UNESCAPED_UNICODE); $log->save(); # 记录日志 } return $next($request); }}

3、中间件引入 ./app/Http/Kernel.php

protected $middlewareGroups = [ 'web' => [ ... \App\Http\Middleware\AdminOperationLog::class, ... ], 'api' => [ 'throttle:60,1', 'bindings', ], ];

此时进行操作时就会记录操作日志

更多关于Laravel相关内容感兴趣的读者可查看本站专题:《Laravel框架入门与进阶教程》、《php优秀开发框架总结》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Laravel框架的PHP程序设计有所帮助。

,如下图

Laravel框架实现利用中间件进行操作日志记录功能

本文实例讲述了Laravel框架实现利用中间件进行操作日志记录功能。分享给大家供大家参考,具体如下:

利用中间件进行操作日志记录过程:

1、创建中间件

php artisan make:middleware AdminOperationLog

2、生成了文件./app/Http/Middleware/AdminOperationLog.php

代码如下:

<?phpnamespace App\Http\Middleware;use Closure;use Illuminate\Http\Request;use Illuminate\Support\Facades\Auth;use App\Http\Models\OperationLog;class AdminOperationLog{ /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user_id = 0; if(Auth::check()) { $user_id = (int) Auth::id(); } $_SERVER['admin_uid'] = $user_id; if('GET' != $request->method()){ $input = $request->all(); $log = new OperationLog(); # 提前创建表、model $log->uid = $user_id; $log->path = $request->path(); $log->method = $request->method(); $log->ip = $request->ip(); $log->sql = ''; $log->input = json_encode($input, JSON_UNESCAPED_UNICODE); $log->save(); # 记录日志 } return $next($request); }}

3、中间件引入 ./app/Http/Kernel.php

protected $middlewareGroups = [ 'web' => [ ... \App\Http\Middleware\AdminOperationLog::class, ... ], 'api' => [ 'throttle:60,1', 'bindings', ], ];

此时进行操作时就会记录操作日志

更多关于Laravel相关内容感兴趣的读者可查看本站专题:《Laravel框架入门与进阶教程》、《php优秀开发框架总结》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Laravel框架的PHP程序设计有所帮助。

,见图

k娱乐百家乐

本文实例讲述了Laravel框架实现利用中间件进行操作日志记录功能。分享给大家供大家参考,具体如下:

利用中间件进行操作日志记录过程:

1、创建中间件

php artisan make:middleware AdminOperationLog

2、生成了文件./app/Http/Middleware/AdminOperationLog.php

代码如下:

<?phpnamespace App\Http\Middleware;use Closure;use Illuminate\Http\Request;use Illuminate\Support\Facades\Auth;use App\Http\Models\OperationLog;class AdminOperationLog{ /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user_id = 0; if(Auth::check()) { $user_id = (int) Auth::id(); } $_SERVER['admin_uid'] = $user_id; if('GET' != $request->method()){ $input = $request->all(); $log = new OperationLog(); # 提前创建表、model $log->uid = $user_id; $log->path = $request->path(); $log->method = $request->method(); $log->ip = $request->ip(); $log->sql = ''; $log->input = json_encode($input, JSON_UNESCAPED_UNICODE); $log->save(); # 记录日志 } return $next($request); }}

3、中间件引入 ./app/Http/Kernel.php

protected $middlewareGroups = [ 'web' => [ ... \App\Http\Middleware\AdminOperationLog::class, ... ], 'api' => [ 'throttle:60,1', 'bindings', ], ];

此时进行操作时就会记录操作日志

更多关于Laravel相关内容感兴趣的读者可查看本站专题:《Laravel框架入门与进阶教程》、《php优秀开发框架总结》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Laravel框架的PHP程序设计有所帮助。

本文实例讲述了Laravel框架实现利用中间件进行操作日志记录功能。分享给大家供大家参考,具体如下:

利用中间件进行操作日志记录过程:

1、创建中间件

php artisan make:middleware AdminOperationLog

2、生成了文件./app/Http/Middleware/AdminOperationLog.php

代码如下:

<?phpnamespace App\Http\Middleware;use Closure;use Illuminate\Http\Request;use Illuminate\Support\Facades\Auth;use App\Http\Models\OperationLog;class AdminOperationLog{ /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user_id = 0; if(Auth::check()) { $user_id = (int) Auth::id(); } $_SERVER['admin_uid'] = $user_id; if('GET' != $request->method()){ $input = $request->all(); $log = new OperationLog(); # 提前创建表、model $log->uid = $user_id; $log->path = $request->path(); $log->method = $request->method(); $log->ip = $request->ip(); $log->sql = ''; $log->input = json_encode($input, JSON_UNESCAPED_UNICODE); $log->save(); # 记录日志 } return $next($request); }}

3、中间件引入 ./app/Http/Kernel.php

protected $middlewareGroups = [ 'web' => [ ... \App\Http\Middleware\AdminOperationLog::class, ... ], 'api' => [ 'throttle:60,1', 'bindings', ], ];

此时进行操作时就会记录操作日志

更多关于Laravel相关内容感兴趣的读者可查看本站专题:《Laravel框架入门与进阶教程》、《php优秀开发框架总结》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Laravel框架的PHP程序设计有所帮助。

Laravel框架实现利用中间件进行操作日志记录功能

Laravel框架实现利用中间件进行操作日志记录功能

Laravel框架实现利用中间件进行操作日志记录功能Laravel框架实现利用中间件进行操作日志记录功能Laravel框架实现利用中间件进行操作日志记录功能

本文实例讲述了Laravel框架实现利用中间件进行操作日志记录功能。分享给大家供大家参考,具体如下:

利用中间件进行操作日志记录过程:

1、创建中间件

php artisan make:middleware AdminOperationLog

2、生成了文件./app/Http/Middleware/AdminOperationLog.php

代码如下:

<?phpnamespace App\Http\Middleware;use Closure;use Illuminate\Http\Request;use Illuminate\Support\Facades\Auth;use App\Http\Models\OperationLog;class AdminOperationLog{ /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user_id = 0; if(Auth::check()) { $user_id = (int) Auth::id(); } $_SERVER['admin_uid'] = $user_id; if('GET' != $request->method()){ $input = $request->all(); $log = new OperationLog(); # 提前创建表、model $log->uid = $user_id; $log->path = $request->path(); $log->method = $request->method(); $log->ip = $request->ip(); $log->sql = ''; $log->input = json_encode($input, JSON_UNESCAPED_UNICODE); $log->save(); # 记录日志 } return $next($request); }}

3、中间件引入 ./app/Http/Kernel.php

protected $middlewareGroups = [ 'web' => [ ... \App\Http\Middleware\AdminOperationLog::class, ... ], 'api' => [ 'throttle:60,1', 'bindings', ], ];

此时进行操作时就会记录操作日志

更多关于Laravel相关内容感兴趣的读者可查看本站专题:《Laravel框架入门与进阶教程》、《php优秀开发框架总结》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Laravel框架的PHP程序设计有所帮助。

本文实例讲述了Laravel框架实现利用中间件进行操作日志记录功能。分享给大家供大家参考,具体如下:

利用中间件进行操作日志记录过程:

1、创建中间件

php artisan make:middleware AdminOperationLog

2、生成了文件./app/Http/Middleware/AdminOperationLog.php

代码如下:

<?phpnamespace App\Http\Middleware;use Closure;use Illuminate\Http\Request;use Illuminate\Support\Facades\Auth;use App\Http\Models\OperationLog;class AdminOperationLog{ /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user_id = 0; if(Auth::check()) { $user_id = (int) Auth::id(); } $_SERVER['admin_uid'] = $user_id; if('GET' != $request->method()){ $input = $request->all(); $log = new OperationLog(); # 提前创建表、model $log->uid = $user_id; $log->path = $request->path(); $log->method = $request->method(); $log->ip = $request->ip(); $log->sql = ''; $log->input = json_encode($input, JSON_UNESCAPED_UNICODE); $log->save(); # 记录日志 } return $next($request); }}

3、中间件引入 ./app/Http/Kernel.php

protected $middlewareGroups = [ 'web' => [ ... \App\Http\Middleware\AdminOperationLog::class, ... ], 'api' => [ 'throttle:60,1', 'bindings', ], ];

此时进行操作时就会记录操作日志

更多关于Laravel相关内容感兴趣的读者可查看本站专题:《Laravel框架入门与进阶教程》、《php优秀开发框架总结》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Laravel框架的PHP程序设计有所帮助。

本文实例讲述了Laravel框架实现利用中间件进行操作日志记录功能。分享给大家供大家参考,具体如下:

利用中间件进行操作日志记录过程:

1、创建中间件

php artisan make:middleware AdminOperationLog

2、生成了文件./app/Http/Middleware/AdminOperationLog.php

代码如下:

<?phpnamespace App\Http\Middleware;use Closure;use Illuminate\Http\Request;use Illuminate\Support\Facades\Auth;use App\Http\Models\OperationLog;class AdminOperationLog{ /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user_id = 0; if(Auth::check()) { $user_id = (int) Auth::id(); } $_SERVER['admin_uid'] = $user_id; if('GET' != $request->method()){ $input = $request->all(); $log = new OperationLog(); # 提前创建表、model $log->uid = $user_id; $log->path = $request->path(); $log->method = $request->method(); $log->ip = $request->ip(); $log->sql = ''; $log->input = json_encode($input, JSON_UNESCAPED_UNICODE); $log->save(); # 记录日志 } return $next($request); }}

3、中间件引入 ./app/Http/Kernel.php

protected $middlewareGroups = [ 'web' => [ ... \App\Http\Middleware\AdminOperationLog::class, ... ], 'api' => [ 'throttle:60,1', 'bindings', ], ];

此时进行操作时就会记录操作日志

更多关于Laravel相关内容感兴趣的读者可查看本站专题:《Laravel框架入门与进阶教程》、《php优秀开发框架总结》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Laravel框架的PHP程序设计有所帮助。

本文实例讲述了Laravel框架实现利用中间件进行操作日志记录功能。分享给大家供大家参考,具体如下:

利用中间件进行操作日志记录过程:

1、创建中间件

php artisan make:middleware AdminOperationLog

2、生成了文件./app/Http/Middleware/AdminOperationLog.php

代码如下:

<?phpnamespace App\Http\Middleware;use Closure;use Illuminate\Http\Request;use Illuminate\Support\Facades\Auth;use App\Http\Models\OperationLog;class AdminOperationLog{ /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user_id = 0; if(Auth::check()) { $user_id = (int) Auth::id(); } $_SERVER['admin_uid'] = $user_id; if('GET' != $request->method()){ $input = $request->all(); $log = new OperationLog(); # 提前创建表、model $log->uid = $user_id; $log->path = $request->path(); $log->method = $request->method(); $log->ip = $request->ip(); $log->sql = ''; $log->input = json_encode($input, JSON_UNESCAPED_UNICODE); $log->save(); # 记录日志 } return $next($request); }}

3、中间件引入 ./app/Http/Kernel.php

protected $middlewareGroups = [ 'web' => [ ... \App\Http\Middleware\AdminOperationLog::class, ... ], 'api' => [ 'throttle:60,1', 'bindings', ], ];

此时进行操作时就会记录操作日志

更多关于Laravel相关内容感兴趣的读者可查看本站专题:《Laravel框架入门与进阶教程》、《php优秀开发框架总结》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Laravel框架的PHP程序设计有所帮助。

本文实例讲述了Laravel框架实现利用中间件进行操作日志记录功能。分享给大家供大家参考,具体如下:

利用中间件进行操作日志记录过程:

1、创建中间件

php artisan make:middleware AdminOperationLog

2、生成了文件./app/Http/Middleware/AdminOperationLog.php

代码如下:

<?phpnamespace App\Http\Middleware;use Closure;use Illuminate\Http\Request;use Illuminate\Support\Facades\Auth;use App\Http\Models\OperationLog;class AdminOperationLog{ /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user_id = 0; if(Auth::check()) { $user_id = (int) Auth::id(); } $_SERVER['admin_uid'] = $user_id; if('GET' != $request->method()){ $input = $request->all(); $log = new OperationLog(); # 提前创建表、model $log->uid = $user_id; $log->path = $request->path(); $log->method = $request->method(); $log->ip = $request->ip(); $log->sql = ''; $log->input = json_encode($input, JSON_UNESCAPED_UNICODE); $log->save(); # 记录日志 } return $next($request); }}

3、中间件引入 ./app/Http/Kernel.php

protected $middlewareGroups = [ 'web' => [ ... \App\Http\Middleware\AdminOperationLog::class, ... ], 'api' => [ 'throttle:60,1', 'bindings', ], ];

此时进行操作时就会记录操作日志

更多关于Laravel相关内容感兴趣的读者可查看本站专题:《Laravel框架入门与进阶教程》、《php优秀开发框架总结》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Laravel框架的PHP程序设计有所帮助。

本文实例讲述了Laravel框架实现利用中间件进行操作日志记录功能。分享给大家供大家参考,具体如下:

利用中间件进行操作日志记录过程:

1、创建中间件

php artisan make:middleware AdminOperationLog

2、生成了文件./app/Http/Middleware/AdminOperationLog.php

代码如下:

<?phpnamespace App\Http\Middleware;use Closure;use Illuminate\Http\Request;use Illuminate\Support\Facades\Auth;use App\Http\Models\OperationLog;class AdminOperationLog{ /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user_id = 0; if(Auth::check()) { $user_id = (int) Auth::id(); } $_SERVER['admin_uid'] = $user_id; if('GET' != $request->method()){ $input = $request->all(); $log = new OperationLog(); # 提前创建表、model $log->uid = $user_id; $log->path = $request->path(); $log->method = $request->method(); $log->ip = $request->ip(); $log->sql = ''; $log->input = json_encode($input, JSON_UNESCAPED_UNICODE); $log->save(); # 记录日志 } return $next($request); }}

3、中间件引入 ./app/Http/Kernel.php

protected $middlewareGroups = [ 'web' => [ ... \App\Http\Middleware\AdminOperationLog::class, ... ], 'api' => [ 'throttle:60,1', 'bindings', ], ];

此时进行操作时就会记录操作日志

更多关于Laravel相关内容感兴趣的读者可查看本站专题:《Laravel框架入门与进阶教程》、《php优秀开发框架总结》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Laravel框架的PHP程序设计有所帮助。

Laravel框架实现利用中间件进行操作日志记录功能

本文实例讲述了Laravel框架实现利用中间件进行操作日志记录功能。分享给大家供大家参考,具体如下:

利用中间件进行操作日志记录过程:

1、创建中间件

php artisan make:middleware AdminOperationLog

2、生成了文件./app/Http/Middleware/AdminOperationLog.php

代码如下:

<?phpnamespace App\Http\Middleware;use Closure;use Illuminate\Http\Request;use Illuminate\Support\Facades\Auth;use App\Http\Models\OperationLog;class AdminOperationLog{ /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user_id = 0; if(Auth::check()) { $user_id = (int) Auth::id(); } $_SERVER['admin_uid'] = $user_id; if('GET' != $request->method()){ $input = $request->all(); $log = new OperationLog(); # 提前创建表、model $log->uid = $user_id; $log->path = $request->path(); $log->method = $request->method(); $log->ip = $request->ip(); $log->sql = ''; $log->input = json_encode($input, JSON_UNESCAPED_UNICODE); $log->save(); # 记录日志 } return $next($request); }}

3、中间件引入 ./app/Http/Kernel.php

protected $middlewareGroups = [ 'web' => [ ... \App\Http\Middleware\AdminOperationLog::class, ... ], 'api' => [ 'throttle:60,1', 'bindings', ], ];

此时进行操作时就会记录操作日志

更多关于Laravel相关内容感兴趣的读者可查看本站专题:《Laravel框架入门与进阶教程》、《php优秀开发框架总结》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Laravel框架的PHP程序设计有所帮助。

本文实例讲述了Laravel框架实现利用中间件进行操作日志记录功能。分享给大家供大家参考,具体如下:

利用中间件进行操作日志记录过程:

1、创建中间件

php artisan make:middleware AdminOperationLog

2、生成了文件./app/Http/Middleware/AdminOperationLog.php

代码如下:

<?phpnamespace App\Http\Middleware;use Closure;use Illuminate\Http\Request;use Illuminate\Support\Facades\Auth;use App\Http\Models\OperationLog;class AdminOperationLog{ /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user_id = 0; if(Auth::check()) { $user_id = (int) Auth::id(); } $_SERVER['admin_uid'] = $user_id; if('GET' != $request->method()){ $input = $request->all(); $log = new OperationLog(); # 提前创建表、model $log->uid = $user_id; $log->path = $request->path(); $log->method = $request->method(); $log->ip = $request->ip(); $log->sql = ''; $log->input = json_encode($input, JSON_UNESCAPED_UNICODE); $log->save(); # 记录日志 } return $next($request); }}

3、中间件引入 ./app/Http/Kernel.php

protected $middlewareGroups = [ 'web' => [ ... \App\Http\Middleware\AdminOperationLog::class, ... ], 'api' => [ 'throttle:60,1', 'bindings', ], ];

此时进行操作时就会记录操作日志

更多关于Laravel相关内容感兴趣的读者可查看本站专题:《Laravel框架入门与进阶教程》、《php优秀开发框架总结》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Laravel框架的PHP程序设计有所帮助。

Laravel框架实现利用中间件进行操作日志记录功能Laravel框架实现利用中间件进行操作日志记录功能Laravel框架实现利用中间件进行操作日志记录功能Laravel框架实现利用中间件进行操作日志记录功能Laravel框架实现利用中间件进行操作日志记录功能

本文实例讲述了Laravel框架实现利用中间件进行操作日志记录功能。分享给大家供大家参考,具体如下:

利用中间件进行操作日志记录过程:

1、创建中间件

php artisan make:middleware AdminOperationLog

2、生成了文件./app/Http/Middleware/AdminOperationLog.php

代码如下:

<?phpnamespace App\Http\Middleware;use Closure;use Illuminate\Http\Request;use Illuminate\Support\Facades\Auth;use App\Http\Models\OperationLog;class AdminOperationLog{ /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user_id = 0; if(Auth::check()) { $user_id = (int) Auth::id(); } $_SERVER['admin_uid'] = $user_id; if('GET' != $request->method()){ $input = $request->all(); $log = new OperationLog(); # 提前创建表、model $log->uid = $user_id; $log->path = $request->path(); $log->method = $request->method(); $log->ip = $request->ip(); $log->sql = ''; $log->input = json_encode($input, JSON_UNESCAPED_UNICODE); $log->save(); # 记录日志 } return $next($request); }}

3、中间件引入 ./app/Http/Kernel.php

protected $middlewareGroups = [ 'web' => [ ... \App\Http\Middleware\AdminOperationLog::class, ... ], 'api' => [ 'throttle:60,1', 'bindings', ], ];

此时进行操作时就会记录操作日志

更多关于Laravel相关内容感兴趣的读者可查看本站专题:《Laravel框架入门与进阶教程》、《php优秀开发框架总结》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Laravel框架的PHP程序设计有所帮助。

Laravel框架实现利用中间件进行操作日志记录功能

本文实例讲述了Laravel框架实现利用中间件进行操作日志记录功能。分享给大家供大家参考,具体如下:

利用中间件进行操作日志记录过程:

1、创建中间件

php artisan make:middleware AdminOperationLog

2、生成了文件./app/Http/Middleware/AdminOperationLog.php

代码如下:

<?phpnamespace App\Http\Middleware;use Closure;use Illuminate\Http\Request;use Illuminate\Support\Facades\Auth;use App\Http\Models\OperationLog;class AdminOperationLog{ /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user_id = 0; if(Auth::check()) { $user_id = (int) Auth::id(); } $_SERVER['admin_uid'] = $user_id; if('GET' != $request->method()){ $input = $request->all(); $log = new OperationLog(); # 提前创建表、model $log->uid = $user_id; $log->path = $request->path(); $log->method = $request->method(); $log->ip = $request->ip(); $log->sql = ''; $log->input = json_encode($input, JSON_UNESCAPED_UNICODE); $log->save(); # 记录日志 } return $next($request); }}

3、中间件引入 ./app/Http/Kernel.php

protected $middlewareGroups = [ 'web' => [ ... \App\Http\Middleware\AdminOperationLog::class, ... ], 'api' => [ 'throttle:60,1', 'bindings', ], ];

此时进行操作时就会记录操作日志

更多关于Laravel相关内容感兴趣的读者可查看本站专题:《Laravel框架入门与进阶教程》、《php优秀开发框架总结》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Laravel框架的PHP程序设计有所帮助。

Laravel框架实现利用中间件进行操作日志记录功能。

Laravel框架实现利用中间件进行操作日志记录功能

k娱乐百家乐

本文实例讲述了Laravel框架实现利用中间件进行操作日志记录功能。分享给大家供大家参考,具体如下:

利用中间件进行操作日志记录过程:

1、创建中间件

php artisan make:middleware AdminOperationLog

2、生成了文件./app/Http/Middleware/AdminOperationLog.php

代码如下:

<?phpnamespace App\Http\Middleware;use Closure;use Illuminate\Http\Request;use Illuminate\Support\Facades\Auth;use App\Http\Models\OperationLog;class AdminOperationLog{ /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user_id = 0; if(Auth::check()) { $user_id = (int) Auth::id(); } $_SERVER['admin_uid'] = $user_id; if('GET' != $request->method()){ $input = $request->all(); $log = new OperationLog(); # 提前创建表、model $log->uid = $user_id; $log->path = $request->path(); $log->method = $request->method(); $log->ip = $request->ip(); $log->sql = ''; $log->input = json_encode($input, JSON_UNESCAPED_UNICODE); $log->save(); # 记录日志 } return $next($request); }}

3、中间件引入 ./app/Http/Kernel.php

protected $middlewareGroups = [ 'web' => [ ... \App\Http\Middleware\AdminOperationLog::class, ... ], 'api' => [ 'throttle:60,1', 'bindings', ], ];

此时进行操作时就会记录操作日志

更多关于Laravel相关内容感兴趣的读者可查看本站专题:《Laravel框架入门与进阶教程》、《php优秀开发框架总结》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Laravel框架的PHP程序设计有所帮助。

Laravel框架实现利用中间件进行操作日志记录功能Laravel框架实现利用中间件进行操作日志记录功能

本文实例讲述了Laravel框架实现利用中间件进行操作日志记录功能。分享给大家供大家参考,具体如下:

利用中间件进行操作日志记录过程:

1、创建中间件

php artisan make:middleware AdminOperationLog

2、生成了文件./app/Http/Middleware/AdminOperationLog.php

代码如下:

<?phpnamespace App\Http\Middleware;use Closure;use Illuminate\Http\Request;use Illuminate\Support\Facades\Auth;use App\Http\Models\OperationLog;class AdminOperationLog{ /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user_id = 0; if(Auth::check()) { $user_id = (int) Auth::id(); } $_SERVER['admin_uid'] = $user_id; if('GET' != $request->method()){ $input = $request->all(); $log = new OperationLog(); # 提前创建表、model $log->uid = $user_id; $log->path = $request->path(); $log->method = $request->method(); $log->ip = $request->ip(); $log->sql = ''; $log->input = json_encode($input, JSON_UNESCAPED_UNICODE); $log->save(); # 记录日志 } return $next($request); }}

3、中间件引入 ./app/Http/Kernel.php

protected $middlewareGroups = [ 'web' => [ ... \App\Http\Middleware\AdminOperationLog::class, ... ], 'api' => [ 'throttle:60,1', 'bindings', ], ];

此时进行操作时就会记录操作日志

更多关于Laravel相关内容感兴趣的读者可查看本站专题:《Laravel框架入门与进阶教程》、《php优秀开发框架总结》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Laravel框架的PHP程序设计有所帮助。

本文实例讲述了Laravel框架实现利用中间件进行操作日志记录功能。分享给大家供大家参考,具体如下:

利用中间件进行操作日志记录过程:

1、创建中间件

php artisan make:middleware AdminOperationLog

2、生成了文件./app/Http/Middleware/AdminOperationLog.php

代码如下:

<?phpnamespace App\Http\Middleware;use Closure;use Illuminate\Http\Request;use Illuminate\Support\Facades\Auth;use App\Http\Models\OperationLog;class AdminOperationLog{ /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user_id = 0; if(Auth::check()) { $user_id = (int) Auth::id(); } $_SERVER['admin_uid'] = $user_id; if('GET' != $request->method()){ $input = $request->all(); $log = new OperationLog(); # 提前创建表、model $log->uid = $user_id; $log->path = $request->path(); $log->method = $request->method(); $log->ip = $request->ip(); $log->sql = ''; $log->input = json_encode($input, JSON_UNESCAPED_UNICODE); $log->save(); # 记录日志 } return $next($request); }}

3、中间件引入 ./app/Http/Kernel.php

protected $middlewareGroups = [ 'web' => [ ... \App\Http\Middleware\AdminOperationLog::class, ... ], 'api' => [ 'throttle:60,1', 'bindings', ], ];

此时进行操作时就会记录操作日志

更多关于Laravel相关内容感兴趣的读者可查看本站专题:《Laravel框架入门与进阶教程》、《php优秀开发框架总结》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Laravel框架的PHP程序设计有所帮助。

Laravel框架实现利用中间件进行操作日志记录功能Laravel框架实现利用中间件进行操作日志记录功能Laravel框架实现利用中间件进行操作日志记录功能Laravel框架实现利用中间件进行操作日志记录功能

本文实例讲述了Laravel框架实现利用中间件进行操作日志记录功能。分享给大家供大家参考,具体如下:

利用中间件进行操作日志记录过程:

1、创建中间件

php artisan make:middleware AdminOperationLog

2、生成了文件./app/Http/Middleware/AdminOperationLog.php

代码如下:

<?phpnamespace App\Http\Middleware;use Closure;use Illuminate\Http\Request;use Illuminate\Support\Facades\Auth;use App\Http\Models\OperationLog;class AdminOperationLog{ /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user_id = 0; if(Auth::check()) { $user_id = (int) Auth::id(); } $_SERVER['admin_uid'] = $user_id; if('GET' != $request->method()){ $input = $request->all(); $log = new OperationLog(); # 提前创建表、model $log->uid = $user_id; $log->path = $request->path(); $log->method = $request->method(); $log->ip = $request->ip(); $log->sql = ''; $log->input = json_encode($input, JSON_UNESCAPED_UNICODE); $log->save(); # 记录日志 } return $next($request); }}

3、中间件引入 ./app/Http/Kernel.php

protected $middlewareGroups = [ 'web' => [ ... \App\Http\Middleware\AdminOperationLog::class, ... ], 'api' => [ 'throttle:60,1', 'bindings', ], ];

此时进行操作时就会记录操作日志

更多关于Laravel相关内容感兴趣的读者可查看本站专题:《Laravel框架入门与进阶教程》、《php优秀开发框架总结》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Laravel框架的PHP程序设计有所帮助。

Laravel框架实现利用中间件进行操作日志记录功能

1.

本文实例讲述了Laravel框架实现利用中间件进行操作日志记录功能。分享给大家供大家参考,具体如下:

利用中间件进行操作日志记录过程:

1、创建中间件

php artisan make:middleware AdminOperationLog

2、生成了文件./app/Http/Middleware/AdminOperationLog.php

代码如下:

<?phpnamespace App\Http\Middleware;use Closure;use Illuminate\Http\Request;use Illuminate\Support\Facades\Auth;use App\Http\Models\OperationLog;class AdminOperationLog{ /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user_id = 0; if(Auth::check()) { $user_id = (int) Auth::id(); } $_SERVER['admin_uid'] = $user_id; if('GET' != $request->method()){ $input = $request->all(); $log = new OperationLog(); # 提前创建表、model $log->uid = $user_id; $log->path = $request->path(); $log->method = $request->method(); $log->ip = $request->ip(); $log->sql = ''; $log->input = json_encode($input, JSON_UNESCAPED_UNICODE); $log->save(); # 记录日志 } return $next($request); }}

3、中间件引入 ./app/Http/Kernel.php

protected $middlewareGroups = [ 'web' => [ ... \App\Http\Middleware\AdminOperationLog::class, ... ], 'api' => [ 'throttle:60,1', 'bindings', ], ];

此时进行操作时就会记录操作日志

更多关于Laravel相关内容感兴趣的读者可查看本站专题:《Laravel框架入门与进阶教程》、《php优秀开发框架总结》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Laravel框架的PHP程序设计有所帮助。

本文实例讲述了Laravel框架实现利用中间件进行操作日志记录功能。分享给大家供大家参考,具体如下:

利用中间件进行操作日志记录过程:

1、创建中间件

php artisan make:middleware AdminOperationLog

2、生成了文件./app/Http/Middleware/AdminOperationLog.php

代码如下:

<?phpnamespace App\Http\Middleware;use Closure;use Illuminate\Http\Request;use Illuminate\Support\Facades\Auth;use App\Http\Models\OperationLog;class AdminOperationLog{ /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user_id = 0; if(Auth::check()) { $user_id = (int) Auth::id(); } $_SERVER['admin_uid'] = $user_id; if('GET' != $request->method()){ $input = $request->all(); $log = new OperationLog(); # 提前创建表、model $log->uid = $user_id; $log->path = $request->path(); $log->method = $request->method(); $log->ip = $request->ip(); $log->sql = ''; $log->input = json_encode($input, JSON_UNESCAPED_UNICODE); $log->save(); # 记录日志 } return $next($request); }}

3、中间件引入 ./app/Http/Kernel.php

protected $middlewareGroups = [ 'web' => [ ... \App\Http\Middleware\AdminOperationLog::class, ... ], 'api' => [ 'throttle:60,1', 'bindings', ], ];

此时进行操作时就会记录操作日志

更多关于Laravel相关内容感兴趣的读者可查看本站专题:《Laravel框架入门与进阶教程》、《php优秀开发框架总结》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Laravel框架的PHP程序设计有所帮助。

Laravel框架实现利用中间件进行操作日志记录功能Laravel框架实现利用中间件进行操作日志记录功能

本文实例讲述了Laravel框架实现利用中间件进行操作日志记录功能。分享给大家供大家参考,具体如下:

利用中间件进行操作日志记录过程:

1、创建中间件

php artisan make:middleware AdminOperationLog

2、生成了文件./app/Http/Middleware/AdminOperationLog.php

代码如下:

<?phpnamespace App\Http\Middleware;use Closure;use Illuminate\Http\Request;use Illuminate\Support\Facades\Auth;use App\Http\Models\OperationLog;class AdminOperationLog{ /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user_id = 0; if(Auth::check()) { $user_id = (int) Auth::id(); } $_SERVER['admin_uid'] = $user_id; if('GET' != $request->method()){ $input = $request->all(); $log = new OperationLog(); # 提前创建表、model $log->uid = $user_id; $log->path = $request->path(); $log->method = $request->method(); $log->ip = $request->ip(); $log->sql = ''; $log->input = json_encode($input, JSON_UNESCAPED_UNICODE); $log->save(); # 记录日志 } return $next($request); }}

3、中间件引入 ./app/Http/Kernel.php

protected $middlewareGroups = [ 'web' => [ ... \App\Http\Middleware\AdminOperationLog::class, ... ], 'api' => [ 'throttle:60,1', 'bindings', ], ];

此时进行操作时就会记录操作日志

更多关于Laravel相关内容感兴趣的读者可查看本站专题:《Laravel框架入门与进阶教程》、《php优秀开发框架总结》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Laravel框架的PHP程序设计有所帮助。

Laravel框架实现利用中间件进行操作日志记录功能

本文实例讲述了Laravel框架实现利用中间件进行操作日志记录功能。分享给大家供大家参考,具体如下:

利用中间件进行操作日志记录过程:

1、创建中间件

php artisan make:middleware AdminOperationLog

2、生成了文件./app/Http/Middleware/AdminOperationLog.php

代码如下:

<?phpnamespace App\Http\Middleware;use Closure;use Illuminate\Http\Request;use Illuminate\Support\Facades\Auth;use App\Http\Models\OperationLog;class AdminOperationLog{ /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user_id = 0; if(Auth::check()) { $user_id = (int) Auth::id(); } $_SERVER['admin_uid'] = $user_id; if('GET' != $request->method()){ $input = $request->all(); $log = new OperationLog(); # 提前创建表、model $log->uid = $user_id; $log->path = $request->path(); $log->method = $request->method(); $log->ip = $request->ip(); $log->sql = ''; $log->input = json_encode($input, JSON_UNESCAPED_UNICODE); $log->save(); # 记录日志 } return $next($request); }}

3、中间件引入 ./app/Http/Kernel.php

protected $middlewareGroups = [ 'web' => [ ... \App\Http\Middleware\AdminOperationLog::class, ... ], 'api' => [ 'throttle:60,1', 'bindings', ], ];

此时进行操作时就会记录操作日志

更多关于Laravel相关内容感兴趣的读者可查看本站专题:《Laravel框架入门与进阶教程》、《php优秀开发框架总结》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Laravel框架的PHP程序设计有所帮助。

Laravel框架实现利用中间件进行操作日志记录功能

本文实例讲述了Laravel框架实现利用中间件进行操作日志记录功能。分享给大家供大家参考,具体如下:

利用中间件进行操作日志记录过程:

1、创建中间件

php artisan make:middleware AdminOperationLog

2、生成了文件./app/Http/Middleware/AdminOperationLog.php

代码如下:

<?phpnamespace App\Http\Middleware;use Closure;use Illuminate\Http\Request;use Illuminate\Support\Facades\Auth;use App\Http\Models\OperationLog;class AdminOperationLog{ /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user_id = 0; if(Auth::check()) { $user_id = (int) Auth::id(); } $_SERVER['admin_uid'] = $user_id; if('GET' != $request->method()){ $input = $request->all(); $log = new OperationLog(); # 提前创建表、model $log->uid = $user_id; $log->path = $request->path(); $log->method = $request->method(); $log->ip = $request->ip(); $log->sql = ''; $log->input = json_encode($input, JSON_UNESCAPED_UNICODE); $log->save(); # 记录日志 } return $next($request); }}

3、中间件引入 ./app/Http/Kernel.php

protected $middlewareGroups = [ 'web' => [ ... \App\Http\Middleware\AdminOperationLog::class, ... ], 'api' => [ 'throttle:60,1', 'bindings', ], ];

此时进行操作时就会记录操作日志

更多关于Laravel相关内容感兴趣的读者可查看本站专题:《Laravel框架入门与进阶教程》、《php优秀开发框架总结》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Laravel框架的PHP程序设计有所帮助。

本文实例讲述了Laravel框架实现利用中间件进行操作日志记录功能。分享给大家供大家参考,具体如下:

利用中间件进行操作日志记录过程:

1、创建中间件

php artisan make:middleware AdminOperationLog

2、生成了文件./app/Http/Middleware/AdminOperationLog.php

代码如下:

<?phpnamespace App\Http\Middleware;use Closure;use Illuminate\Http\Request;use Illuminate\Support\Facades\Auth;use App\Http\Models\OperationLog;class AdminOperationLog{ /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user_id = 0; if(Auth::check()) { $user_id = (int) Auth::id(); } $_SERVER['admin_uid'] = $user_id; if('GET' != $request->method()){ $input = $request->all(); $log = new OperationLog(); # 提前创建表、model $log->uid = $user_id; $log->path = $request->path(); $log->method = $request->method(); $log->ip = $request->ip(); $log->sql = ''; $log->input = json_encode($input, JSON_UNESCAPED_UNICODE); $log->save(); # 记录日志 } return $next($request); }}

3、中间件引入 ./app/Http/Kernel.php

protected $middlewareGroups = [ 'web' => [ ... \App\Http\Middleware\AdminOperationLog::class, ... ], 'api' => [ 'throttle:60,1', 'bindings', ], ];

此时进行操作时就会记录操作日志

更多关于Laravel相关内容感兴趣的读者可查看本站专题:《Laravel框架入门与进阶教程》、《php优秀开发框架总结》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Laravel框架的PHP程序设计有所帮助。

本文实例讲述了Laravel框架实现利用中间件进行操作日志记录功能。分享给大家供大家参考,具体如下:

利用中间件进行操作日志记录过程:

1、创建中间件

php artisan make:middleware AdminOperationLog

2、生成了文件./app/Http/Middleware/AdminOperationLog.php

代码如下:

<?phpnamespace App\Http\Middleware;use Closure;use Illuminate\Http\Request;use Illuminate\Support\Facades\Auth;use App\Http\Models\OperationLog;class AdminOperationLog{ /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user_id = 0; if(Auth::check()) { $user_id = (int) Auth::id(); } $_SERVER['admin_uid'] = $user_id; if('GET' != $request->method()){ $input = $request->all(); $log = new OperationLog(); # 提前创建表、model $log->uid = $user_id; $log->path = $request->path(); $log->method = $request->method(); $log->ip = $request->ip(); $log->sql = ''; $log->input = json_encode($input, JSON_UNESCAPED_UNICODE); $log->save(); # 记录日志 } return $next($request); }}

3、中间件引入 ./app/Http/Kernel.php

protected $middlewareGroups = [ 'web' => [ ... \App\Http\Middleware\AdminOperationLog::class, ... ], 'api' => [ 'throttle:60,1', 'bindings', ], ];

此时进行操作时就会记录操作日志

更多关于Laravel相关内容感兴趣的读者可查看本站专题:《Laravel框架入门与进阶教程》、《php优秀开发框架总结》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Laravel框架的PHP程序设计有所帮助。

本文实例讲述了Laravel框架实现利用中间件进行操作日志记录功能。分享给大家供大家参考,具体如下:

利用中间件进行操作日志记录过程:

1、创建中间件

php artisan make:middleware AdminOperationLog

2、生成了文件./app/Http/Middleware/AdminOperationLog.php

代码如下:

<?phpnamespace App\Http\Middleware;use Closure;use Illuminate\Http\Request;use Illuminate\Support\Facades\Auth;use App\Http\Models\OperationLog;class AdminOperationLog{ /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user_id = 0; if(Auth::check()) { $user_id = (int) Auth::id(); } $_SERVER['admin_uid'] = $user_id; if('GET' != $request->method()){ $input = $request->all(); $log = new OperationLog(); # 提前创建表、model $log->uid = $user_id; $log->path = $request->path(); $log->method = $request->method(); $log->ip = $request->ip(); $log->sql = ''; $log->input = json_encode($input, JSON_UNESCAPED_UNICODE); $log->save(); # 记录日志 } return $next($request); }}

3、中间件引入 ./app/Http/Kernel.php

protected $middlewareGroups = [ 'web' => [ ... \App\Http\Middleware\AdminOperationLog::class, ... ], 'api' => [ 'throttle:60,1', 'bindings', ], ];

此时进行操作时就会记录操作日志

更多关于Laravel相关内容感兴趣的读者可查看本站专题:《Laravel框架入门与进阶教程》、《php优秀开发框架总结》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Laravel框架的PHP程序设计有所帮助。

本文实例讲述了Laravel框架实现利用中间件进行操作日志记录功能。分享给大家供大家参考,具体如下:

利用中间件进行操作日志记录过程:

1、创建中间件

php artisan make:middleware AdminOperationLog

2、生成了文件./app/Http/Middleware/AdminOperationLog.php

代码如下:

<?phpnamespace App\Http\Middleware;use Closure;use Illuminate\Http\Request;use Illuminate\Support\Facades\Auth;use App\Http\Models\OperationLog;class AdminOperationLog{ /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user_id = 0; if(Auth::check()) { $user_id = (int) Auth::id(); } $_SERVER['admin_uid'] = $user_id; if('GET' != $request->method()){ $input = $request->all(); $log = new OperationLog(); # 提前创建表、model $log->uid = $user_id; $log->path = $request->path(); $log->method = $request->method(); $log->ip = $request->ip(); $log->sql = ''; $log->input = json_encode($input, JSON_UNESCAPED_UNICODE); $log->save(); # 记录日志 } return $next($request); }}

3、中间件引入 ./app/Http/Kernel.php

protected $middlewareGroups = [ 'web' => [ ... \App\Http\Middleware\AdminOperationLog::class, ... ], 'api' => [ 'throttle:60,1', 'bindings', ], ];

此时进行操作时就会记录操作日志

更多关于Laravel相关内容感兴趣的读者可查看本站专题:《Laravel框架入门与进阶教程》、《php优秀开发框架总结》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Laravel框架的PHP程序设计有所帮助。

Laravel框架实现利用中间件进行操作日志记录功能

本文实例讲述了Laravel框架实现利用中间件进行操作日志记录功能。分享给大家供大家参考,具体如下:

利用中间件进行操作日志记录过程:

1、创建中间件

php artisan make:middleware AdminOperationLog

2、生成了文件./app/Http/Middleware/AdminOperationLog.php

代码如下:

<?phpnamespace App\Http\Middleware;use Closure;use Illuminate\Http\Request;use Illuminate\Support\Facades\Auth;use App\Http\Models\OperationLog;class AdminOperationLog{ /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user_id = 0; if(Auth::check()) { $user_id = (int) Auth::id(); } $_SERVER['admin_uid'] = $user_id; if('GET' != $request->method()){ $input = $request->all(); $log = new OperationLog(); # 提前创建表、model $log->uid = $user_id; $log->path = $request->path(); $log->method = $request->method(); $log->ip = $request->ip(); $log->sql = ''; $log->input = json_encode($input, JSON_UNESCAPED_UNICODE); $log->save(); # 记录日志 } return $next($request); }}

3、中间件引入 ./app/Http/Kernel.php

protected $middlewareGroups = [ 'web' => [ ... \App\Http\Middleware\AdminOperationLog::class, ... ], 'api' => [ 'throttle:60,1', 'bindings', ], ];

此时进行操作时就会记录操作日志

更多关于Laravel相关内容感兴趣的读者可查看本站专题:《Laravel框架入门与进阶教程》、《php优秀开发框架总结》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Laravel框架的PHP程序设计有所帮助。

本文实例讲述了Laravel框架实现利用中间件进行操作日志记录功能。分享给大家供大家参考,具体如下:

利用中间件进行操作日志记录过程:

1、创建中间件

php artisan make:middleware AdminOperationLog

2、生成了文件./app/Http/Middleware/AdminOperationLog.php

代码如下:

<?phpnamespace App\Http\Middleware;use Closure;use Illuminate\Http\Request;use Illuminate\Support\Facades\Auth;use App\Http\Models\OperationLog;class AdminOperationLog{ /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user_id = 0; if(Auth::check()) { $user_id = (int) Auth::id(); } $_SERVER['admin_uid'] = $user_id; if('GET' != $request->method()){ $input = $request->all(); $log = new OperationLog(); # 提前创建表、model $log->uid = $user_id; $log->path = $request->path(); $log->method = $request->method(); $log->ip = $request->ip(); $log->sql = ''; $log->input = json_encode($input, JSON_UNESCAPED_UNICODE); $log->save(); # 记录日志 } return $next($request); }}

3、中间件引入 ./app/Http/Kernel.php

protected $middlewareGroups = [ 'web' => [ ... \App\Http\Middleware\AdminOperationLog::class, ... ], 'api' => [ 'throttle:60,1', 'bindings', ], ];

此时进行操作时就会记录操作日志

更多关于Laravel相关内容感兴趣的读者可查看本站专题:《Laravel框架入门与进阶教程》、《php优秀开发框架总结》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Laravel框架的PHP程序设计有所帮助。

2.

本文实例讲述了Laravel框架实现利用中间件进行操作日志记录功能。分享给大家供大家参考,具体如下:

利用中间件进行操作日志记录过程:

1、创建中间件

php artisan make:middleware AdminOperationLog

2、生成了文件./app/Http/Middleware/AdminOperationLog.php

代码如下:

<?phpnamespace App\Http\Middleware;use Closure;use Illuminate\Http\Request;use Illuminate\Support\Facades\Auth;use App\Http\Models\OperationLog;class AdminOperationLog{ /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user_id = 0; if(Auth::check()) { $user_id = (int) Auth::id(); } $_SERVER['admin_uid'] = $user_id; if('GET' != $request->method()){ $input = $request->all(); $log = new OperationLog(); # 提前创建表、model $log->uid = $user_id; $log->path = $request->path(); $log->method = $request->method(); $log->ip = $request->ip(); $log->sql = ''; $log->input = json_encode($input, JSON_UNESCAPED_UNICODE); $log->save(); # 记录日志 } return $next($request); }}

3、中间件引入 ./app/Http/Kernel.php

protected $middlewareGroups = [ 'web' => [ ... \App\Http\Middleware\AdminOperationLog::class, ... ], 'api' => [ 'throttle:60,1', 'bindings', ], ];

此时进行操作时就会记录操作日志

更多关于Laravel相关内容感兴趣的读者可查看本站专题:《Laravel框架入门与进阶教程》、《php优秀开发框架总结》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Laravel框架的PHP程序设计有所帮助。

Laravel框架实现利用中间件进行操作日志记录功能

本文实例讲述了Laravel框架实现利用中间件进行操作日志记录功能。分享给大家供大家参考,具体如下:

利用中间件进行操作日志记录过程:

1、创建中间件

php artisan make:middleware AdminOperationLog

2、生成了文件./app/Http/Middleware/AdminOperationLog.php

代码如下:

<?phpnamespace App\Http\Middleware;use Closure;use Illuminate\Http\Request;use Illuminate\Support\Facades\Auth;use App\Http\Models\OperationLog;class AdminOperationLog{ /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user_id = 0; if(Auth::check()) { $user_id = (int) Auth::id(); } $_SERVER['admin_uid'] = $user_id; if('GET' != $request->method()){ $input = $request->all(); $log = new OperationLog(); # 提前创建表、model $log->uid = $user_id; $log->path = $request->path(); $log->method = $request->method(); $log->ip = $request->ip(); $log->sql = ''; $log->input = json_encode($input, JSON_UNESCAPED_UNICODE); $log->save(); # 记录日志 } return $next($request); }}

3、中间件引入 ./app/Http/Kernel.php

protected $middlewareGroups = [ 'web' => [ ... \App\Http\Middleware\AdminOperationLog::class, ... ], 'api' => [ 'throttle:60,1', 'bindings', ], ];

此时进行操作时就会记录操作日志

更多关于Laravel相关内容感兴趣的读者可查看本站专题:《Laravel框架入门与进阶教程》、《php优秀开发框架总结》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Laravel框架的PHP程序设计有所帮助。

Laravel框架实现利用中间件进行操作日志记录功能Laravel框架实现利用中间件进行操作日志记录功能

3.Laravel框架实现利用中间件进行操作日志记录功能。

本文实例讲述了Laravel框架实现利用中间件进行操作日志记录功能。分享给大家供大家参考,具体如下:

利用中间件进行操作日志记录过程:

1、创建中间件

php artisan make:middleware AdminOperationLog

2、生成了文件./app/Http/Middleware/AdminOperationLog.php

代码如下:

<?phpnamespace App\Http\Middleware;use Closure;use Illuminate\Http\Request;use Illuminate\Support\Facades\Auth;use App\Http\Models\OperationLog;class AdminOperationLog{ /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user_id = 0; if(Auth::check()) { $user_id = (int) Auth::id(); } $_SERVER['admin_uid'] = $user_id; if('GET' != $request->method()){ $input = $request->all(); $log = new OperationLog(); # 提前创建表、model $log->uid = $user_id; $log->path = $request->path(); $log->method = $request->method(); $log->ip = $request->ip(); $log->sql = ''; $log->input = json_encode($input, JSON_UNESCAPED_UNICODE); $log->save(); # 记录日志 } return $next($request); }}

3、中间件引入 ./app/Http/Kernel.php

protected $middlewareGroups = [ 'web' => [ ... \App\Http\Middleware\AdminOperationLog::class, ... ], 'api' => [ 'throttle:60,1', 'bindings', ], ];

此时进行操作时就会记录操作日志

更多关于Laravel相关内容感兴趣的读者可查看本站专题:《Laravel框架入门与进阶教程》、《php优秀开发框架总结》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Laravel框架的PHP程序设计有所帮助。

本文实例讲述了Laravel框架实现利用中间件进行操作日志记录功能。分享给大家供大家参考,具体如下:

利用中间件进行操作日志记录过程:

1、创建中间件

php artisan make:middleware AdminOperationLog

2、生成了文件./app/Http/Middleware/AdminOperationLog.php

代码如下:

<?phpnamespace App\Http\Middleware;use Closure;use Illuminate\Http\Request;use Illuminate\Support\Facades\Auth;use App\Http\Models\OperationLog;class AdminOperationLog{ /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user_id = 0; if(Auth::check()) { $user_id = (int) Auth::id(); } $_SERVER['admin_uid'] = $user_id; if('GET' != $request->method()){ $input = $request->all(); $log = new OperationLog(); # 提前创建表、model $log->uid = $user_id; $log->path = $request->path(); $log->method = $request->method(); $log->ip = $request->ip(); $log->sql = ''; $log->input = json_encode($input, JSON_UNESCAPED_UNICODE); $log->save(); # 记录日志 } return $next($request); }}

3、中间件引入 ./app/Http/Kernel.php

protected $middlewareGroups = [ 'web' => [ ... \App\Http\Middleware\AdminOperationLog::class, ... ], 'api' => [ 'throttle:60,1', 'bindings', ], ];

此时进行操作时就会记录操作日志

更多关于Laravel相关内容感兴趣的读者可查看本站专题:《Laravel框架入门与进阶教程》、《php优秀开发框架总结》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Laravel框架的PHP程序设计有所帮助。

Laravel框架实现利用中间件进行操作日志记录功能Laravel框架实现利用中间件进行操作日志记录功能Laravel框架实现利用中间件进行操作日志记录功能Laravel框架实现利用中间件进行操作日志记录功能

本文实例讲述了Laravel框架实现利用中间件进行操作日志记录功能。分享给大家供大家参考,具体如下:

利用中间件进行操作日志记录过程:

1、创建中间件

php artisan make:middleware AdminOperationLog

2、生成了文件./app/Http/Middleware/AdminOperationLog.php

代码如下:

<?phpnamespace App\Http\Middleware;use Closure;use Illuminate\Http\Request;use Illuminate\Support\Facades\Auth;use App\Http\Models\OperationLog;class AdminOperationLog{ /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user_id = 0; if(Auth::check()) { $user_id = (int) Auth::id(); } $_SERVER['admin_uid'] = $user_id; if('GET' != $request->method()){ $input = $request->all(); $log = new OperationLog(); # 提前创建表、model $log->uid = $user_id; $log->path = $request->path(); $log->method = $request->method(); $log->ip = $request->ip(); $log->sql = ''; $log->input = json_encode($input, JSON_UNESCAPED_UNICODE); $log->save(); # 记录日志 } return $next($request); }}

3、中间件引入 ./app/Http/Kernel.php

protected $middlewareGroups = [ 'web' => [ ... \App\Http\Middleware\AdminOperationLog::class, ... ], 'api' => [ 'throttle:60,1', 'bindings', ], ];

此时进行操作时就会记录操作日志

更多关于Laravel相关内容感兴趣的读者可查看本站专题:《Laravel框架入门与进阶教程》、《php优秀开发框架总结》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Laravel框架的PHP程序设计有所帮助。

4.

本文实例讲述了Laravel框架实现利用中间件进行操作日志记录功能。分享给大家供大家参考,具体如下:

利用中间件进行操作日志记录过程:

1、创建中间件

php artisan make:middleware AdminOperationLog

2、生成了文件./app/Http/Middleware/AdminOperationLog.php

代码如下:

<?phpnamespace App\Http\Middleware;use Closure;use Illuminate\Http\Request;use Illuminate\Support\Facades\Auth;use App\Http\Models\OperationLog;class AdminOperationLog{ /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user_id = 0; if(Auth::check()) { $user_id = (int) Auth::id(); } $_SERVER['admin_uid'] = $user_id; if('GET' != $request->method()){ $input = $request->all(); $log = new OperationLog(); # 提前创建表、model $log->uid = $user_id; $log->path = $request->path(); $log->method = $request->method(); $log->ip = $request->ip(); $log->sql = ''; $log->input = json_encode($input, JSON_UNESCAPED_UNICODE); $log->save(); # 记录日志 } return $next($request); }}

3、中间件引入 ./app/Http/Kernel.php

protected $middlewareGroups = [ 'web' => [ ... \App\Http\Middleware\AdminOperationLog::class, ... ], 'api' => [ 'throttle:60,1', 'bindings', ], ];

此时进行操作时就会记录操作日志

更多关于Laravel相关内容感兴趣的读者可查看本站专题:《Laravel框架入门与进阶教程》、《php优秀开发框架总结》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Laravel框架的PHP程序设计有所帮助。

Laravel框架实现利用中间件进行操作日志记录功能

本文实例讲述了Laravel框架实现利用中间件进行操作日志记录功能。分享给大家供大家参考,具体如下:

利用中间件进行操作日志记录过程:

1、创建中间件

php artisan make:middleware AdminOperationLog

2、生成了文件./app/Http/Middleware/AdminOperationLog.php

代码如下:

<?phpnamespace App\Http\Middleware;use Closure;use Illuminate\Http\Request;use Illuminate\Support\Facades\Auth;use App\Http\Models\OperationLog;class AdminOperationLog{ /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user_id = 0; if(Auth::check()) { $user_id = (int) Auth::id(); } $_SERVER['admin_uid'] = $user_id; if('GET' != $request->method()){ $input = $request->all(); $log = new OperationLog(); # 提前创建表、model $log->uid = $user_id; $log->path = $request->path(); $log->method = $request->method(); $log->ip = $request->ip(); $log->sql = ''; $log->input = json_encode($input, JSON_UNESCAPED_UNICODE); $log->save(); # 记录日志 } return $next($request); }}

3、中间件引入 ./app/Http/Kernel.php

protected $middlewareGroups = [ 'web' => [ ... \App\Http\Middleware\AdminOperationLog::class, ... ], 'api' => [ 'throttle:60,1', 'bindings', ], ];

此时进行操作时就会记录操作日志

更多关于Laravel相关内容感兴趣的读者可查看本站专题:《Laravel框架入门与进阶教程》、《php优秀开发框架总结》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Laravel框架的PHP程序设计有所帮助。

Laravel框架实现利用中间件进行操作日志记录功能

本文实例讲述了Laravel框架实现利用中间件进行操作日志记录功能。分享给大家供大家参考,具体如下:

利用中间件进行操作日志记录过程:

1、创建中间件

php artisan make:middleware AdminOperationLog

2、生成了文件./app/Http/Middleware/AdminOperationLog.php

代码如下:

<?phpnamespace App\Http\Middleware;use Closure;use Illuminate\Http\Request;use Illuminate\Support\Facades\Auth;use App\Http\Models\OperationLog;class AdminOperationLog{ /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user_id = 0; if(Auth::check()) { $user_id = (int) Auth::id(); } $_SERVER['admin_uid'] = $user_id; if('GET' != $request->method()){ $input = $request->all(); $log = new OperationLog(); # 提前创建表、model $log->uid = $user_id; $log->path = $request->path(); $log->method = $request->method(); $log->ip = $request->ip(); $log->sql = ''; $log->input = json_encode($input, JSON_UNESCAPED_UNICODE); $log->save(); # 记录日志 } return $next($request); }}

3、中间件引入 ./app/Http/Kernel.php

protected $middlewareGroups = [ 'web' => [ ... \App\Http\Middleware\AdminOperationLog::class, ... ], 'api' => [ 'throttle:60,1', 'bindings', ], ];

此时进行操作时就会记录操作日志

更多关于Laravel相关内容感兴趣的读者可查看本站专题:《Laravel框架入门与进阶教程》、《php优秀开发框架总结》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Laravel框架的PHP程序设计有所帮助。

本文实例讲述了Laravel框架实现利用中间件进行操作日志记录功能。分享给大家供大家参考,具体如下:

利用中间件进行操作日志记录过程:

1、创建中间件

php artisan make:middleware AdminOperationLog

2、生成了文件./app/Http/Middleware/AdminOperationLog.php

代码如下:

<?phpnamespace App\Http\Middleware;use Closure;use Illuminate\Http\Request;use Illuminate\Support\Facades\Auth;use App\Http\Models\OperationLog;class AdminOperationLog{ /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user_id = 0; if(Auth::check()) { $user_id = (int) Auth::id(); } $_SERVER['admin_uid'] = $user_id; if('GET' != $request->method()){ $input = $request->all(); $log = new OperationLog(); # 提前创建表、model $log->uid = $user_id; $log->path = $request->path(); $log->method = $request->method(); $log->ip = $request->ip(); $log->sql = ''; $log->input = json_encode($input, JSON_UNESCAPED_UNICODE); $log->save(); # 记录日志 } return $next($request); }}

3、中间件引入 ./app/Http/Kernel.php

protected $middlewareGroups = [ 'web' => [ ... \App\Http\Middleware\AdminOperationLog::class, ... ], 'api' => [ 'throttle:60,1', 'bindings', ], ];

此时进行操作时就会记录操作日志

更多关于Laravel相关内容感兴趣的读者可查看本站专题:《Laravel框架入门与进阶教程》、《php优秀开发框架总结》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Laravel框架的PHP程序设计有所帮助。

本文实例讲述了Laravel框架实现利用中间件进行操作日志记录功能。分享给大家供大家参考,具体如下:

利用中间件进行操作日志记录过程:

1、创建中间件

php artisan make:middleware AdminOperationLog

2、生成了文件./app/Http/Middleware/AdminOperationLog.php

代码如下:

<?phpnamespace App\Http\Middleware;use Closure;use Illuminate\Http\Request;use Illuminate\Support\Facades\Auth;use App\Http\Models\OperationLog;class AdminOperationLog{ /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user_id = 0; if(Auth::check()) { $user_id = (int) Auth::id(); } $_SERVER['admin_uid'] = $user_id; if('GET' != $request->method()){ $input = $request->all(); $log = new OperationLog(); # 提前创建表、model $log->uid = $user_id; $log->path = $request->path(); $log->method = $request->method(); $log->ip = $request->ip(); $log->sql = ''; $log->input = json_encode($input, JSON_UNESCAPED_UNICODE); $log->save(); # 记录日志 } return $next($request); }}

3、中间件引入 ./app/Http/Kernel.php

protected $middlewareGroups = [ 'web' => [ ... \App\Http\Middleware\AdminOperationLog::class, ... ], 'api' => [ 'throttle:60,1', 'bindings', ], ];

此时进行操作时就会记录操作日志

更多关于Laravel相关内容感兴趣的读者可查看本站专题:《Laravel框架入门与进阶教程》、《php优秀开发框架总结》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Laravel框架的PHP程序设计有所帮助。

本文实例讲述了Laravel框架实现利用中间件进行操作日志记录功能。分享给大家供大家参考,具体如下:

利用中间件进行操作日志记录过程:

1、创建中间件

php artisan make:middleware AdminOperationLog

2、生成了文件./app/Http/Middleware/AdminOperationLog.php

代码如下:

<?phpnamespace App\Http\Middleware;use Closure;use Illuminate\Http\Request;use Illuminate\Support\Facades\Auth;use App\Http\Models\OperationLog;class AdminOperationLog{ /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user_id = 0; if(Auth::check()) { $user_id = (int) Auth::id(); } $_SERVER['admin_uid'] = $user_id; if('GET' != $request->method()){ $input = $request->all(); $log = new OperationLog(); # 提前创建表、model $log->uid = $user_id; $log->path = $request->path(); $log->method = $request->method(); $log->ip = $request->ip(); $log->sql = ''; $log->input = json_encode($input, JSON_UNESCAPED_UNICODE); $log->save(); # 记录日志 } return $next($request); }}

3、中间件引入 ./app/Http/Kernel.php

protected $middlewareGroups = [ 'web' => [ ... \App\Http\Middleware\AdminOperationLog::class, ... ], 'api' => [ 'throttle:60,1', 'bindings', ], ];

此时进行操作时就会记录操作日志

更多关于Laravel相关内容感兴趣的读者可查看本站专题:《Laravel框架入门与进阶教程》、《php优秀开发框架总结》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Laravel框架的PHP程序设计有所帮助。

本文实例讲述了Laravel框架实现利用中间件进行操作日志记录功能。分享给大家供大家参考,具体如下:

利用中间件进行操作日志记录过程:

1、创建中间件

php artisan make:middleware AdminOperationLog

2、生成了文件./app/Http/Middleware/AdminOperationLog.php

代码如下:

<?phpnamespace App\Http\Middleware;use Closure;use Illuminate\Http\Request;use Illuminate\Support\Facades\Auth;use App\Http\Models\OperationLog;class AdminOperationLog{ /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user_id = 0; if(Auth::check()) { $user_id = (int) Auth::id(); } $_SERVER['admin_uid'] = $user_id; if('GET' != $request->method()){ $input = $request->all(); $log = new OperationLog(); # 提前创建表、model $log->uid = $user_id; $log->path = $request->path(); $log->method = $request->method(); $log->ip = $request->ip(); $log->sql = ''; $log->input = json_encode($input, JSON_UNESCAPED_UNICODE); $log->save(); # 记录日志 } return $next($request); }}

3、中间件引入 ./app/Http/Kernel.php

protected $middlewareGroups = [ 'web' => [ ... \App\Http\Middleware\AdminOperationLog::class, ... ], 'api' => [ 'throttle:60,1', 'bindings', ], ];

此时进行操作时就会记录操作日志

更多关于Laravel相关内容感兴趣的读者可查看本站专题:《Laravel框架入门与进阶教程》、《php优秀开发框架总结》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Laravel框架的PHP程序设计有所帮助。

Laravel框架实现利用中间件进行操作日志记录功能Laravel框架实现利用中间件进行操作日志记录功能Laravel框架实现利用中间件进行操作日志记录功能。k娱乐百家乐

展开全文
相关文章
新宝gg游戏现金网

Laravel框架实现利用中间件进行操作日志记录功能

国内最信的过娱乐平台

本文实例讲述了Laravel框架实现利用中间件进行操作日志记录功能。分享给大家供大家参考,具体如下:

利用中间件进行操作日志记录过程:

1、创建中间件

php artisan make:middleware AdminOperationLog

2、生成了文件./app/Http/Middleware/AdminOperationLog.php

代码如下:

<?phpnamespace App\Http\Middleware;use Closure;use Illuminate\Http\Request;use Illuminate\Support\Facades\Auth;use App\Http\Models\OperationLog;class AdminOperationLog{ /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user_id = 0; if(Auth::check()) { $user_id = (int) Auth::id(); } $_SERVER['admin_uid'] = $user_id; if('GET' != $request->method()){ $input = $request->all(); $log = new OperationLog(); # 提前创建表、model $log->uid = $user_id; $log->path = $request->path(); $log->method = $request->method(); $log->ip = $request->ip(); $log->sql = ''; $log->input = json_encode($input, JSON_UNESCAPED_UNICODE); $log->save(); # 记录日志 } return $next($request); }}

3、中间件引入 ./app/Http/Kernel.php

protected $middlewareGroups = [ 'web' => [ ... \App\Http\Middleware\AdminOperationLog::class, ... ], 'api' => [ 'throttle:60,1', 'bindings', ], ];

此时进行操作时就会记录操作日志

更多关于Laravel相关内容感兴趣的读者可查看本站专题:《Laravel框架入门与进阶教程》、《php优秀开发框架总结》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Laravel框架的PHP程序设计有所帮助。

....

澳门威尼斯人登录平台

Laravel框架实现利用中间件进行操作日志记录功能....

新太阳城娱乐能赚钱吗

本文实例讲述了Laravel框架实现利用中间件进行操作日志记录功能。分享给大家供大家参考,具体如下:

利用中间件进行操作日志记录过程:

1、创建中间件

php artisan make:middleware AdminOperationLog

2、生成了文件./app/Http/Middleware/AdminOperationLog.php

代码如下:

<?phpnamespace App\Http\Middleware;use Closure;use Illuminate\Http\Request;use Illuminate\Support\Facades\Auth;use App\Http\Models\OperationLog;class AdminOperationLog{ /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user_id = 0; if(Auth::check()) { $user_id = (int) Auth::id(); } $_SERVER['admin_uid'] = $user_id; if('GET' != $request->method()){ $input = $request->all(); $log = new OperationLog(); # 提前创建表、model $log->uid = $user_id; $log->path = $request->path(); $log->method = $request->method(); $log->ip = $request->ip(); $log->sql = ''; $log->input = json_encode($input, JSON_UNESCAPED_UNICODE); $log->save(); # 记录日志 } return $next($request); }}

3、中间件引入 ./app/Http/Kernel.php

protected $middlewareGroups = [ 'web' => [ ... \App\Http\Middleware\AdminOperationLog::class, ... ], 'api' => [ 'throttle:60,1', 'bindings', ], ];

此时进行操作时就会记录操作日志

更多关于Laravel相关内容感兴趣的读者可查看本站专题:《Laravel框架入门与进阶教程》、《php优秀开发框架总结》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Laravel框架的PHP程序设计有所帮助。

....

微信公众号没有提示音

本文实例讲述了Laravel框架实现利用中间件进行操作日志记录功能。分享给大家供大家参考,具体如下:

利用中间件进行操作日志记录过程:

1、创建中间件

php artisan make:middleware AdminOperationLog

2、生成了文件./app/Http/Middleware/AdminOperationLog.php

代码如下:

<?phpnamespace App\Http\Middleware;use Closure;use Illuminate\Http\Request;use Illuminate\Support\Facades\Auth;use App\Http\Models\OperationLog;class AdminOperationLog{ /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user_id = 0; if(Auth::check()) { $user_id = (int) Auth::id(); } $_SERVER['admin_uid'] = $user_id; if('GET' != $request->method()){ $input = $request->all(); $log = new OperationLog(); # 提前创建表、model $log->uid = $user_id; $log->path = $request->path(); $log->method = $request->method(); $log->ip = $request->ip(); $log->sql = ''; $log->input = json_encode($input, JSON_UNESCAPED_UNICODE); $log->save(); # 记录日志 } return $next($request); }}

3、中间件引入 ./app/Http/Kernel.php

protected $middlewareGroups = [ 'web' => [ ... \App\Http\Middleware\AdminOperationLog::class, ... ], 'api' => [ 'throttle:60,1', 'bindings', ], ];

此时进行操作时就会记录操作日志

更多关于Laravel相关内容感兴趣的读者可查看本站专题:《Laravel框架入门与进阶教程》、《php优秀开发框架总结》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Laravel框架的PHP程序设计有所帮助。

....

相关资讯
广州网站建设c2c

本文实例讲述了Laravel框架实现利用中间件进行操作日志记录功能。分享给大家供大家参考,具体如下:

利用中间件进行操作日志记录过程:

1、创建中间件

php artisan make:middleware AdminOperationLog

2、生成了文件./app/Http/Middleware/AdminOperationLog.php

代码如下:

<?phpnamespace App\Http\Middleware;use Closure;use Illuminate\Http\Request;use Illuminate\Support\Facades\Auth;use App\Http\Models\OperationLog;class AdminOperationLog{ /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $user_id = 0; if(Auth::check()) { $user_id = (int) Auth::id(); } $_SERVER['admin_uid'] = $user_id; if('GET' != $request->method()){ $input = $request->all(); $log = new OperationLog(); # 提前创建表、model $log->uid = $user_id; $log->path = $request->path(); $log->method = $request->method(); $log->ip = $request->ip(); $log->sql = ''; $log->input = json_encode($input, JSON_UNESCAPED_UNICODE); $log->save(); # 记录日志 } return $next($request); }}

3、中间件引入 ./app/Http/Kernel.php

protected $middlewareGroups = [ 'web' => [ ... \App\Http\Middleware\AdminOperationLog::class, ... ], 'api' => [ 'throttle:60,1', 'bindings', ], ];

此时进行操作时就会记录操作日志

更多关于Laravel相关内容感兴趣的读者可查看本站专题:《Laravel框架入门与进阶教程》、《php优秀开发框架总结》、《php面向对象程序设计入门教程》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于Laravel框架的PHP程序设计有所帮助。

....

热门资讯