class UserActivityLoggerMiddleware
{
public function handle(Request $request, Closure $next)
{
dd($request->route());
// dd(Route::currentRouteAction());
// dd($request->user('staffCompany')->offices()->get());
$offices = $request->user('staffCompany')->offices()->get()->toArray();
$path = 'app/office-logger/'. $offices[0]['company_id'] .'/'. $offices[0]['id'] .'/'.date('Y').'/'.date('d-m-Y').'.log';
$message = 'Рудди';
$context = ['user' => 'lalala'];
// dd($path);
Log::channel('custom')->pushHandler(new StreamHandler(storage_path($path), Logger::DEBUG))->info($message, $context);
return $next($request);
}
}
Illuminate\Routing\Route {#218 ▼
+uri: "livewire/message/{name}"
+methods: array:1 [▼
0 => "POST"
]
+action: array:3 [▼
"uses" => "Livewire\Controllers\HttpConnectionHandler@__invoke"
"controller" => "Livewire\Controllers\HttpConnectionHandler"
"middleware" => array:2 [▼
0 => "web"
1 => "logger"
]
]
+isFallback: false
+controller: Livewire\Controllers\HttpConnectionHandler {#456}
+defaults: []
+wheres: []
+parameters: array:1 [▼
"name" => "console.manage.data.city"
]
+parameterNames: array:1 [▼
0 => "name"
]
#originalParameters: array:1 [▼
"name" => "console.manage.data.city"
]
public function delete(int $id){
if(Model::destroy($id)){
Только тут мы логируем использую текущего юзера, ид записи и тд
}
}
->load(['reports' => function ($query) use ($request){
$query
->orderBy('date_report', 'desc')
->when($request['data']['interval'] == '9', function ($query) use ($request) {
return $query
->where('date_report', '>=', $request['data']['intervals']['from'])
->where('date_report', '<=', $request['data']['intervals']['to']);
}, function ($query) use ($request) {
return $query->limit($request['data']['interval']);
});
}])
string(51) "["#ff0000","#00ff00","#9bfc94","#a99dcc","#eeb363"]"
array(5) { [0]=> string(7) "#ff0000" [1]=> string(7) "#00ff00" [2]=> string(7) "#9bfc94" [3]=> string(7) "#a99dcc" [4]=> string(7) "#eeb363" }
dd($request->route()); внутри - это