public function upload($request, $file)
 {
     $rand = Random::quick(20);
     if ($file) {
         $filename = $rand . "." . $file->getClientOriginalExtension();
         $file->move('uploads', $filename);
     } else {
         if (array_has($request, 'file_url')) {
             $image = Image::make(array_get($request, 'file_url'));
             $mime = $image->mime();
             //edited due to updated to 2.x
             if ($mime == 'image/jpeg') {
                 $extension = '.jpg';
             } elseif ($mime == 'image/png') {
                 $extension = '.png';
             } elseif ($mime == 'image/gif') {
                 $extension = '.gif';
             } else {
                 $extension = '';
             }
             $filename = $rand . $extension;
             $image->save(public_path('uploads/' . $filename));
         } else {
             throw new Exception("NO IMAGE PROVIDED");
         }
     }
     $data = ['filename' => $filename, 'scope' => array_get($request, 'scope'), 'scope_id' => array_get($request, 'scope_id')];
     return $this->model->create($data);
 }
 public function returnToken($credentials)
 {
     $claims = ['jti' => md5($credentials['email'] . time() . Random::quick())];
     return JWTAuth::attempt($credentials, $claims);
 }