/** * 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.']; } }
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); } }