/**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     // We want to delete the table if it exists before running the seed
     DB::table('testimonials')->delete();
     $seederData = array(['image' => 'test.png', 'description' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.', 'author' => 'shota'], ['image' => 'test.png', 'description' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.', 'author' => 'shota'], ['image' => 'test.png', 'description' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.', 'author' => 'shota']);
     foreach ($seederData as $item) {
         Testimonial::create($item);
     }
 }
 public function addTestimonial(TestimonialRequest $request)
 {
     // Google recaptcha settings
     $url = 'https://www.google.com/recaptcha/api/siteverify';
     $data = ['secret' => env('GOOGLE_CAPTCHA_SECRET', ''), 'response' => $request->get('g-recaptcha-response')];
     // send data to Google Recaptcha.
     $options = ['http' => ['header' => "Content-type: application/x-www-form-urlencoded\r\n", 'method' => 'POST', 'content' => http_build_query($data)]];
     $context = stream_context_create($options);
     $response = json_decode(file_get_contents($url, false, $context), true);
     //verify google catpcha is valid
     if (!isset($response['success']) || !$response['success']) {
         flash('CAPTCHA non valide', 'error');
         return redirect()->back()->withInput();
     }
     Testimonial::create(['ip' => $_SERVER['REMOTE_ADDR'], 'content' => $request->get('content'), 'status' => 'waiting']);
     flash('Votre témoigagne a bien été envoyé.');
     return redirect()->back();
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(TestimonialRequest $request)
 {
     Testimonial::create(['content' => $request->get('content'), 'ip' => $_SERVER['REMOTE_ADDR'], 'status' => 'published']);
     flash('Testimonial added with sucessfully');
     return redirect()->route('admin-testimonials.index');
 }