/
proc
/
3430793
/
cwd
/
home
/
maktab
/
server
/
app
/
Http
/
Middleware
/
File Upload :
llllll
Current File: //proc/3430793/cwd/home/maktab/server/app/Http/Middleware/ValidationMiddleware.php
<?php namespace App\Http\Middleware; use Closure; use Illuminate\Support\Facades\Validator; use Illuminate\Support\Str; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException; class ValidationMiddleware { /** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if($request->acceptsJson()){ $str = Str::of($request->path())->contains('attendance'); if ($str){ if (auth('user')->user()->type == 6){ throw new UnprocessableEntityHttpException(); } } $method = $request->getMethod(); $path =$request->path(); if(preg_match('/[0-9]+$/',$request->path(),$match)) { $path = preg_replace('/[0-9]+$/', '{id}', $request->path()); } $format = 'validation.'.$path.'@'.strtolower($method); if (config($format)) { if ($path == 'cu/customer'){ $replace = preg_replace('/cu_update_id/', auth()->id(), config($format)); $validator = Validator::make($request->all(), $replace); } elseif(isset($match[0])){ $replace = preg_replace('/id/', $match[0], config($format)); $validator = Validator::make($request->all(), $replace); }else{ $validator = Validator::make($request->all(), config($format)); } if ($validator->fails()) { return response()->json($validator->errors(),422); } } return $next($request); } throw new BadRequestHttpException(); } }
Copyright ©2k19 -
Hexid
|
Tex7ure