Exemplo n.º 1
0
 public function createnewKey(Request $request)
 {
     $salt = hash('sha256', time() . mt_rand());
     $new_key = substr($salt, 0, 40);
     $key = new key();
     $key->key = $new_key;
     if ($key->save()) {
         return $this->httpCreate();
     }
 }
Exemplo n.º 2
0
 public function show(Request $request)
 {
     //
     $url = $request->input('input_data');
     $key = $this->getUniqueRandomKey();
     if ($request->ajax()) {
         $data = new key();
         $data->url = $url;
         $data->key = $key;
         $data->user_id = '1';
         $data->ip = $request->getClientIp();
         $data->save();
         //checking the url repetition and if repeated then returning the old one
         if ($this->checkUrlRepetition($url)) {
             $repeated_key = DB::table('keys')->where('keys.url', '=', $url)->value('key');
             $full_url = "http://ucut.in/" . $repeated_key;
         } else {
             $full_url = "http://ucut.in/" . $key;
         }
         return response()->json(['message' => 'created', 'url' => $full_url]);
     }
 }