public function postShowAdd()
 {
     $validation_data = ['title' => 'required|min:3', 'testimonial' => 'required|min:10'];
     // Validate data
     $validator = new Validator();
     $errors = $validator->isValid($validation_data);
     if (sizeof($errors) > 0) {
         \App\libs\session\Session::flash('errors', $errors);
         echo $this->blade->render('add-testimonials');
         exit;
     }
     $testimonial = new Testimonial();
     $testimonial->title = $_POST['title'];
     $testimonial->testimonial = $_POST['testimonial'];
     $testimonial->user_id = LoggedIn::user()->id;
     $testimonial->save();
     header('Location: /testimonial-saved');
     exit;
 }
 /**
  * Fungsi untuk menghapus testimony
  * @param  [type] $id [description]
  * @return [type]     [description]
  */
 public function destroy($id)
 {
     $testimony = Testimonial::find($id);
     if ($testimony) {
         if ($testimony->delete()) {
             return ['status' => 'success', 'message' => 'Testimony berhasil dihapus.'];
         } else {
             return ['status' => 'failed', 'message' => 'Testimony gagal dihapus.'];
         }
     } else {
         return ['status' => 'failed', 'message' => 'Testimony tidak tersedia.'];
     }
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     //
     Schema::create('testimonials', function (Blueprint $table) {
         $table->increments('id');
         $table->string('author');
         $table->string('title')->nullable();
         $table->string('company');
         $table->text('quote');
         $table->string('photo')->nullable();
         $table->timestamps();
         $table->timestamp('published')->nullable();
         $table->softDeletes();
     });
     Testimonial::create(['author' => 'Dan Hughes', 'title' => 'CEO', 'company' => 'PT Northwest LLC', 'quote' => 'Not only good speakers, but excellent scheduling to allow for good opportunities for networking.', 'published' => Carbon::create(2015, 00, 28, 15, 05, 29)]);
     Testimonial::create(['author' => 'Jon Turino', 'company' => 'COUNTRY Financial', 'quote' => 'The diverse program for this event has a little something for everyone.', 'published' => Carbon::create(2015, 00, 28, 15, 05, 29)]);
     Testimonial::create(['author' => 'Cynthia Wetlesen', 'title' => 'Owner', 'company' => 'Affordable Insurance Strategies', 'quote' => 'The speakers and topics were pertinent and beneficial.', 'published' => Carbon::create(2015, 00, 28, 15, 05, 29)]);
     Testimonial::create(['author' => 'Sam Darcy', 'title' => 'CEO', 'company' => 'Astoria Pointe', 'quote' => 'Professional delivery of relevant topics.  Looking forward to the next event.', 'published' => Carbon::create(2015, 00, 28, 15, 05, 29)]);
 }
 public function get($id, $elequent)
 {
     $cacheKey = self::CACHE . $id;
     if ($elequent) {
         return Testimonial::find($id);
     }
     $cachedData = \Cache::has($cacheKey);
     if (empty($cachedData)) {
         $testimonial = Testimonial::find($id);
         if (!empty($testimonial)) {
             $testimonial = $testimonial->toArray();
             if (!empty($testimonial['pic_path'])) {
                 $testimonial['image'] = env('STORAGE_URL') . 'testimonial_images/' . $testimonial['pic_path'];
             } else {
                 $testimonial['image'] = '';
             }
             $testimonial['updated_at'] = date('Y-m-d', strtotime($testimonial['updated_at']));
             $testimonial['created_at_formatted'] = date('Y-m-d', strtotime($testimonial['created_at']));
             $testimonial['updated_at_formatted'] = date('Y-m-d', strtotime($testimonial['updated_at']));
             // unset($country['password']);
             //unset($country['code']);
             // Set data in cache
             \Cache::forever($cacheKey, $testimonial);
             return $testimonial;
         } else {
             return false;
         }
     } else {
         return \Cache::get($cacheKey);
     }
 }