Beispiel #1
0
 /**
  * Responds to requests to GET /books
  */
 public function getTextResults(Request $request)
 {
     $pnum = $request->input('pnum');
     $generator = new Generator();
     $paragraphs = $generator->getParagraphs($pnum);
     return view('text.results')->with(['paragraphs' => $paragraphs]);
 }
Beispiel #2
0
 public function postCreate($paragraphs = null)
 {
     //generate lorem-ipsum paragraphs using Badcow\LoremIpsum\Generator
     $generator = new Generator();
     $paragraphs = $generator->getParagraphs($_POST['number']);
     return view('loremipsum.createAndShow')->with('paragraphs', $paragraphs);
 }
 public function postIndex(Request $request)
 {
     $num_paragraphs = $request->input('num_paragraphs');
     $generator = new Generator();
     $paragraphs = $generator->getParagraphs($num_paragraphs);
     return view('lorem_ipsum')->with('paragraphs', $paragraphs)->with('formdata', $this->formdata);
 }
 public function postRandomUser(Request $request)
 {
     //Validate that Number of Users is integer
     $this->validate($request, ['noOfUsers' => 'required|numeric']);
     $contents = Storage::get('libraries/Names.txt');
     $content_array = explode('<@>', $contents);
     $noOfUsers = $request->input('noOfUsers');
     $withProfile = $request->input('withProfile');
     $users = array();
     $content_array_size = sizeof($content_array);
     for ($i = 0; $i < $noOfUsers; $i++) {
         $random = new \Rych\Random\Random();
         $randomNumber = $random->getRandomInteger(0, $content_array_size - 1);
         $name = $content_array[$randomNumber];
         $email = str_replace(" ", "_", $name);
         $email = "Email:\n" . $email . "@webdevelopment.info.com" . "\n\n";
         if ($withProfile == 'Yes') {
             $generator = new Generator();
             $profile = $generator->getParagraphs(1);
             $profile = implode('<p>', $profile);
             $email = $email . "Profile:\n" . $profile;
         }
         $randomNumber = $random->getRandomInteger(1, 5);
         $userPic = 'img\\User_' . $randomNumber . '.jpg';
         $users[$name] = array($email, $userPic);
     }
     return view('randomuser.randomUser')->with('title', 'Random User Generator')->with('users', $users);
 }
Beispiel #5
0
 public function postLorem(Request $request)
 {
     $this->validate($request, ['number_of_paragraphs' => 'required|numeric|min:1|max:99']);
     $data = $request['number_of_paragraphs'];
     $generator = new LoremIpsum\Generator();
     $paragraphs = $generator->getParagraphs($data);
     return view('loremipsum.postindex')->with(['paragraphs' => $paragraphs]);
 }
Beispiel #6
0
 /**
  * Posts the results
  */
 public function postText(Request $request)
 {
     $this->validate($request, ['paragraphCount' => 'numeric|required|min:1|max:99']);
     $paraNum = $request->input('paragraphCount');
     $gen = new Generator();
     $para = $gen->getParagraphs($paraNum);
     return view("lorem", ["para" => $para]);
 }
 /**
  * Responds to requests to POST /loremipsum
  */
 public function postIndex(Request $request)
 {
     $this->validate($request, ['grafs' => 'required|numeric|min:1|max:10']);
     $grafs = $request->input('grafs');
     $generator = new Generator();
     $paragraphs = $generator->getParagraphs($grafs);
     return view('loremipsum')->with('paragraphs', $paragraphs)->with('grafs', $grafs);
 }
 public function testGetSingleParagraph_noSrand()
 {
     $gen = new Generator();
     for ($i = 0; $i < 1000; $i++) {
         $para = $gen->getParagraphs(1);
         $this->assertTrue($para[0] !== '', "Failed on iteration #{$i}");
     }
 }
Beispiel #9
0
 public function goIpsumPost(Request $request = null)
 {
     $this->validate($request, ['paragraphs' => 'required|min:1']);
     $num = $request->input('paragraphs');
     $generator = new Generator();
     $paragraphs = $generator->getParagraphs($num);
     //echo implode('<p>', $paragraphs);
     return view('ipsum')->with('paragraphs', $paragraphs)->with('num_para', $num);
 }
 public function postLoremIpsum(Request $request)
 {
     //validate paragraph number input
     $this->validate($request, ['paragraph_number' => 'required|integer|between:1,99']);
     $generator = new Generator();
     $paragraphsCount = $request->input('paragraph_number');
     $paragraphs = $generator->getParagraphs($paragraphsCount);
     return view('loremipsum.index')->with('paragraphs', $paragraphs)->with('paragraphsCount', $paragraphsCount);
 }
Beispiel #11
0
 public function loremstore(LoremFormRequest $request)
 {
     //return \Redirect::route('contact');
     // $paragraph = $request->input('paragraph');
     $generator = new Generator();
     $paragraphs = $request->input('paragraph');
     $userparagraph = $generator->getParagraphs($paragraphs);
     return view('store.loremstore')->with('userparagraph', $userparagraph);
 }
 public function postLoremIpsum(Request $request)
 {
     //Validate that Number of Paragraphs is integer
     $this->validate($request, ['noOfParas' => 'required|numeric']);
     $noOfParas = $request->input('noOfParas');
     $generator = new Generator();
     $paragraphs = $generator->getParagraphs($noOfParas);
     return view('loremipsum.loremIpsum')->with('title', 'Lorem Ipsum Generator')->with('paragraphs', $paragraphs);
 }
 public function testToSentence()
 {
     $gen = new Generator();
     $sentences = $gen->getSentences(64);
     foreach ($sentences as $sentence) {
         /** @var string $sentence */
         $this->assertRegExp('/^[A-Z][a-z, ]+\\.$/', $sentence, sprintf('Failed to assert "%s" was a valid sentence.', $sentence));
     }
 }
Beispiel #14
0
 /**
  * Responds to requests to POST /lorem
  */
 public function postLorem(Request $request)
 {
     $this->validate($request, ['paragraphs' => 'required|integer|min:1|max:99']);
     $paragraphs = $request->input('paragraphs');
     $generator = new Generator();
     $text = $generator->getParagraphs($paragraphs);
     $request->flash();
     return view('lorem.post')->with('text', $text);
 }
Beispiel #15
0
 public function generateText(Request $request)
 {
     //validation: input must be numeric, the field is required, and min  value is 1
     $this->validate($request, ['number_of_paraghraphs' => 'required|numeric|min:1']);
     $number = $request->input('number_of_paraghraphs');
     $generator = new Generator();
     $result = $generator->getParagraphs($number);
     return view('p3.lorem_ipsum')->with('result', $result);
 }
Beispiel #16
0
 public function postResults(Request $request)
 {
     //Max 999 paragraphs. Must be numeric value.
     $this->validate($request, ['inputParagraphs' => 'required|numeric|max:999']);
     $data = $request->all();
     $generator = new Generator();
     $paragraphs = $generator->getParagraphs($data['inputParagraphs']);
     return view('LoremIpsum.results')->with(['data' => $data, 'paragraphs' => $paragraphs]);
 }
Beispiel #17
0
 /**
  * Responds to requests to POST /lorem
  */
 public function postLorem(Request $request)
 {
     $this->validateLorem($request);
     // delete input values if reset button clicked
     if ($request->has('reset')) {
         $request->flush();
         return view('lorem')->withTitle($this->title)->withSitetitle($this->siteTitle);
     }
     $qty = $request->input('quantity');
     $paragraphs = '';
     $content = '';
     // generator choice
     switch ($request->input('generator')) {
         case 'faker':
             $faker = Faker::create();
             $paragraphs = $faker->paragraphs($qty);
             break;
         case 'elvish':
             $generator = new ElvishGenerator();
             $paragraphs = $generator->getParagraphs($qty);
             break;
         default:
             $generator = new Badcow\Generator();
             $paragraphs = $generator->getParagraphs($qty);
     }
     // output choice
     switch ($request->input('format')) {
         // comma separated values wrapped in parens ()
         case 'php':
             for ($i = 0; $i < $qty; $i++) {
                 if ($i == 0) {
                     $content .= '(  ';
                 } else {
                     $content .= ' , ';
                 }
                 $content .= "'{$paragraphs[$i]}'\n";
             }
             $content .= ');';
             break;
         case 'html':
             foreach ($paragraphs as $paragraph) {
                 $content .= "<p>{$paragraph}</p>\n";
             }
             break;
         case 'json':
             $content = json_encode($paragraphs);
             break;
         default:
             foreach ($paragraphs as $paragraph) {
                 $content .= "{$paragraph}\n\n";
             }
     }
     // store input in session
     $request->flash();
     return view('lorem')->withTitle($this->title)->withContent($content)->withSitetitle($this->siteTitle);
 }
Beispiel #18
0
 public function postLorem(Request $request)
 {
     $this->validate($request, ['num_paragraph' => 'required|Integer|max:10|min:1']);
     //Generate Lorem paragraphs
     $generator = new Generator();
     $num_paragraph = $request->input('num_paragraph');
     $paragraphs = $generator->getParagraphs($num_paragraph);
     return view('lorem.display')->with('paragraphs', $paragraphs);
     dd($request->all());
 }
Beispiel #19
0
 public function postIndex(Request $request)
 {
     //Validate number of dummies
     $this->validate($request, ['number' => 'required|numeric']);
     //Generate Paragrtaphs
     $generator = new \Badcow\LoremIpsum\Generator();
     $paragraphs = $generator->getParagraphs(\Input::get('number'));
     //  dd($paragraphs);
     return view('lorem.postIndex')->with(['paragraphs' => $paragraphs]);
 }
Beispiel #20
0
 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function postIndex(Request $request)
 {
     //
     $this->validate($request, ['para' => 'required|integer|min:1|max:10']);
     $data = $request->all();
     $count = $data['para'];
     //dd($request->all());
     $generator = new LoremIpsum\Generator();
     $text_data = $generator->getParagraphs($count);
     return view('LI.postindex')->with(['data' => $data, 'paragraphs' => $text_data]);
 }
Beispiel #21
0
 public function postLorem(Request $request)
 {
     $this->validate($request, ['numParagraphs' => 'required|numeric']);
     //generate new text
     $generator = new Badcow\LoremIpsum\Generator();
     $paragraphs = $generator->getParagraphs($request['numParagraphs']);
     //return $paragraphs;
     return view('lorem.postindex')->with(['paragraphs' => $paragraphs]);
     //dd($request)->all();
     //return "here's your Lorem Ipsum text";
 }
Beispiel #22
0
 public function postIpsum(Request $request)
 {
     //validate
     $this->validate($request, ['numParagraphs' => 'required|integer|min:1|max:20']);
     //create generator
     $generator = new LoremIpsum\Generator();
     //pass number from form into variable $number
     $number = $request->input('numParagraphs');
     //pass the variable $number into the generator
     $paragraphs = $generator->getParagraphs($number);
     return view('home', compact('paragraphs'));
 }
 public function generateLoremIpsum($count, $type)
 {
     $generator = new LoremIpsum\Generator();
     if ($type == 'paragraphs') {
         $lorem_ipsum = $generator->getParagraphs($count);
     } elseif ($type == 'words') {
         $lorem_ipsum = $generator->getRandomWords($count);
     } else {
         $lorem_ipsum = $generator->getSentences($count);
     }
     return $lorem_ipsum;
 }
 /**
  * Generate a number of text paragraphs and return via JSON
  *
  * @return Response in JSON
  */
 public function text($paragraphs = 1, $json = true)
 {
     $generator = new LoremIpsum();
     // Generate desired number of text paragraphs
     $paragraphs = $generator->getParagraphs($paragraphs);
     // Return JSON or generic object response
     if ($json) {
         return response()->json($paragraphs);
     } else {
         return $paragraphs;
     }
 }
 public function postPage(Request $request)
 {
     // validation
     $this->validate($request, ['number' => 'required|numeric|max:88|min:1']);
     $numberOfParagraphs = $request->input('number');
     $generator = new LoremGenerator();
     $paragraphs = $generator->getParagraphs($numberOfParagraphs);
     //$data = implode('<p>', $paragraphs);
     //dd($paragraphs);
     return view('developers.loremTool')->with(['paragraphs' => $paragraphs]);
     //return 'Generating Lorem Text ' . $request->input('number');
 }
Beispiel #26
0
 public function postPage(Request $request)
 {
     // Validate the request data
     $this->validate($request, ['paragraph' => 'required|in:1,2,3,4,5,6,7,8,9,10']);
     // Passed validation now time to generate Ipsum Text
     $paragraph = $request->input('paragraph');
     //New Instance of Lorem Ipsum Generator Class
     $generator = new LoremIpsum\Generator();
     //Get paragraphs of text
     $value = $generator->getParagraphs($paragraph);
     //Return array value containing Lorem Ipsum text back to blade template (ipsum.blade.php)
     return view('ipsum', ['value' => $value]);
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function getIndex(Request $request)
 {
     if ($request->input('numParagraphs')) {
         // Validate form input for (1) required, (2) must be numeric, and (3) can not be a negative number.
         $this->validate($request, ['numParagraphs' => 'required|numeric|min:1|max:10']);
         // Create new Lorem Ipsum Object
         $generator = new Generator();
         // Generate x number of paragraphs based on user input
         $paragraphs = $generator->getParagraphs($request->input('numParagraphs'));
         // return view with an array of paragraphs
         return view('lorem.index')->with(['paragraphs' => $paragraphs]);
     } else {
         return view('lorem.index');
     }
 }
 public function generate()
 {
     $input = Input::get('number');
     if (!ctype_digit($input)) {
         return Redirect::back()->with('message', 'You did not enter a number!');
     }
     $input = intval($input);
     if ($input < 0 || $input > 99) {
         return Redirect::back()->with('message', 'You have to enter number between 1 to 99!');
     }
     $generator = new LoremIpsum\Generator();
     $paragraphs = $generator->getParagraphs($input);
     $generated = array();
     foreach ($paragraphs as $paragraph) {
         $generated[] = "<p>" . $paragraph . "</p>";
     }
     $generated = implode("", $generated);
     return view('loremipsum')->with('generated', $generated);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     // Validate form
     $this->validate($request, ['text_type' => 'required|in:words,sentences,paragraphs', 'text_quantity' => 'required|integer|between:1,100']);
     // Assign variables
     $text_type = $request->input('text_type');
     $text_quantity = $request->input('text_quantity');
     // Generate Lorem Ipsum Data
     $generator = new Generator();
     if ($text_type == 'words') {
         $text_data = $generator->getRandomWords($text_quantity);
     } elseif ($text_type == 'sentences') {
         $text_data = $generator->getSentences($text_quantity);
     } elseif ($text_type == 'paragraphs') {
         $text_data = $generator->getParagraphs($text_quantity);
     } else {
         // If both frontend and backend validation fail...
         return view('errors.error');
     }
     // Push data to view and return view
     //echo implode('<p>', $text_data;
     return view('results', ['payload' => $text_data, 'source' => 'lorem-ipsum', 'title' => 'Lorem Ipsum Generator']);
 }
Beispiel #30
0
 public function postLoremipsum()
 {
     //Array to hold validation rules.
     $rules = array('number' => 'numeric|max:99|min:1');
     //Array of error messages
     $messages = array('min' => 'Please enter a number greater than 0.', 'max' => 'Please enter a number less than 100.', 'numeric' => 'Please enter a number between 1 and 99.');
     // Create a new validator instance.
     $validator = Validator::make(Input::all(), $rules, $messages);
     //Validate the user's input.
     if ($validator->passes()) {
         $postData = Input::get('number');
         //Create new lorem ipsum object.
         $generator = new Generator();
         //Generate array of paragraphs.
         $paragraphs = $generator->getParagraphs($postData);
         //Format paragraphs for view.
         $paragraphData = implode('<p>', $paragraphs);
         //Return data to view.
         return $paragraphData;
     } else {
         $errors = $validator->messages();
         return response($errors = $errors, $status = '400');
     }
 }