Guest User

Untitled

a guest
Jun 20th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. public function store(GeckoRequest $request)
  2. {
  3. $user_id = Auth::user()->id;
  4. $input = $request->all();
  5.  
  6. $input['genetics'] = json_encode($input['genetics'], JSON_FORCE_OBJECT);
  7. $input['user_id'] = $user_id;
  8.  
  9. Gecko::create($input);
  10.  
  11. $name = str_replace(' ', '-', $request['name']);
  12.  
  13. flash()->success('Success!', 'Your gecko has been added to the system');
  14. return redirect()->action('GeckoController@show', [$name]);
  15.  
  16. }
  17.  
  18. public function randomId(){
  19.  
  20. $id = str_random(10);
  21.  
  22. $validator = Validator::make(['id'=>$id],['id'=>'unique:table,col']);
  23.  
  24. if($validator->fails()){
  25. return $this->randomId();
  26. }
  27.  
  28. return $id;
  29. }
  30.  
  31. do
  32. {
  33. $code = // generate your code
  34. $gecko_code = Gecko::where('code', $code)->first();
  35. }
  36. while(!empty($gecko_code));
Add Comment
Please, Sign In to add comment