コード例 #1
0
 /**
  * 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);
     }
 }
コード例 #2
0
 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();
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $testimonial = Testimonial::whereid($id)->firstOrFail();
     $testimonial->delete();
     return redirect('/testimonials')->with('status', 'The Testimonial information has been deleted!');
 }
 public function publicShow($id)
 {
     $training = Training::whereid($id)->firstOrFail();
     $courses = Course::wheretraining_id($id)->get();
     $testimonials = Testimonial::wheretraining_id($id)->get();
     return view('trainings.public_training_pages.show', compact('training'), compact('courses'))->with('testimonials', $testimonials);
 }
コード例 #5
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     // get $testimonials
     $testimonials = Testimonial::all();
     return $testimonials;
 }
コード例 #6
0
 /**
  * Return json response to ajax request and change the status of the testimonial
  */
 private function update_status($id, $new_status)
 {
     $testimonial = Testimonial::find($id);
     if (is_null($testimonial)) {
         return response()->json(['message' => 'Testimonial not found'], 400);
     }
     $testimonial->status = $new_status;
     $testimonial->save();
     return response()->json(['message' => 'Status updated with success'], 200);
 }
コード例 #7
0
 public function getDatatable()
 {
     $news = Testimonial::leftJoin('customers', 'testimonials.cust_name', '=', 'customers.id')->select(array('testimonials.id', 'testimonials.image', 'testimonials.cust_name as name', 'testimonials.testimonial'));
     return Datatables::of($news)->addColumn('image', function ($news) {
         return '<img src="../' . $news->image . '"class="img-responsive" width="50" height="50"></img>';
     })->addColumn('action', function ($news) {
         return '<a href="testimonial/edit/' . $news->id . '" class="btn btn-xs btn-primary">Edit</a> <a href="testimonial/delete/' . $news->id . '" class="btn btn-xs btn-danger">Delete</a>';
     })->removeColumn('created_at', 'update_at')->make(true);
 }