/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (User::where('id', '=', $request->segment(3))->get()->isEmpty()) { return response()->json(['error' => 'User not found!'], 404); } return $next($request); }
/** * Update user in database * @param array $data * @param User $user User model */ public static function editProfile($data, User $user) { $user->update($data); }