/**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     do {
         $videoCode = self::VIDEO_PRE_CODE . StringUtil::getRandomString();
         $courses = Course::where('video_code', $videoCode)->first();
         if (empty($courses)) {
             $request['video_code'] = $videoCode;
             break;
         }
     } while (true);
     return $next($request);
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $itemType = ItemType::find($request['item_type_id']);
     do {
         $itemCode = $itemType->pre_code . self::DASH . StringUtil::getRandomString();
         $items = Item::where('item_code', $itemCode)->first();
         if (empty($items)) {
             $request['item_code'] = $itemCode;
             break;
         }
     } while (true);
     return $next($request);
 }