74 lines
3.7 KiB
PHP
74 lines
3.7 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\Cache;
|
|
|
|
class WelcomeController extends Controller
|
|
{
|
|
public function index()
|
|
{
|
|
$articles = Cache::remember('rss_articles', 3600, function () {
|
|
$articleController = new ArticleController();
|
|
$articles = $articleController->fetchArticles();
|
|
return !empty($articles) ? $articles : $this->getDummyArticles();
|
|
});
|
|
|
|
return view('welcome', compact('articles'));
|
|
}
|
|
|
|
private function getDummyArticles()
|
|
{
|
|
return [
|
|
[
|
|
'title' => 'Teknologi Pertanian Modern Tingkatkan Produktivitas Tebu',
|
|
'link' => 'https://www.pertanian.go.id',
|
|
'excerpt' => 'Penerapan teknologi pertanian presisi dan sistem pakar membantu petani meningkatkan hasil panen hingga 30%.',
|
|
'date' => date('d M Y'),
|
|
'source' => 'Kementerian Pertanian',
|
|
'image' => 'https://images.unsplash.com/photo-1625246333195-78d9c38ad449?w=600&q=80',
|
|
],
|
|
[
|
|
'title' => 'Cara Mencegah Penyakit Karat Daun pada Tanaman Tebu',
|
|
'link' => 'https://cybex.pertanian.go.id',
|
|
'excerpt' => 'Penyakit karat daun menjadi ancaman serius bagi perkebunan tebu. Deteksi dini dan penanganan tepat sangat penting.',
|
|
'date' => date('d M Y', strtotime('-2 days')),
|
|
'source' => 'CYBEX Pertanian',
|
|
'image' => 'https://images.unsplash.com/photo-1574943320219-553eb213f72d?w=600&q=80',
|
|
],
|
|
[
|
|
'title' => 'Inovasi Sistem Pakar untuk Diagnosis Penyakit Tanaman',
|
|
'link' => 'https://www.pertanian.go.id',
|
|
'excerpt' => 'Sistem pakar berbasis AI menggunakan metode Certainty Factor terbukti efektif dalam mendiagnosis penyakit tanaman.',
|
|
'date' => date('d M Y', strtotime('-5 days')),
|
|
'source' => 'Litbang Pertanian',
|
|
'image' => 'https://images.unsplash.com/photo-1416879595882-3373a0480b5b?w=600&q=80',
|
|
],
|
|
[
|
|
'title' => 'Budidaya Tebu Organik Ramah Lingkungan',
|
|
'link' => 'https://www.pertanian.go.id',
|
|
'excerpt' => 'Metode budidaya organik tidak hanya ramah lingkungan tetapi juga menghasilkan tebu berkualitas tinggi.',
|
|
'date' => date('d M Y', strtotime('-7 days')),
|
|
'source' => 'Kementerian Pertanian',
|
|
'image' => 'https://images.unsplash.com/photo-1464226184884-fa280b87c399?w=600&q=80',
|
|
],
|
|
[
|
|
'title' => 'Pelatihan Petani dalam Identifikasi Penyakit Tanaman',
|
|
'link' => 'https://cybex.pertanian.go.id',
|
|
'excerpt' => 'Program pelatihan nasional membekali petani dengan kemampuan mengenali gejala awal penyakit tanaman.',
|
|
'date' => date('d M Y', strtotime('-10 days')),
|
|
'source' => 'CYBEX Pertanian',
|
|
'image' => 'https://images.unsplash.com/photo-1500651230702-0e2d8a49d4ad?w=600&q=80',
|
|
],
|
|
[
|
|
'title' => 'Riset Varietas Tebu Tahan Penyakit',
|
|
'link' => 'https://www.pertanian.go.id',
|
|
'excerpt' => 'Penelitian terbaru berhasil mengembangkan varietas tebu unggul yang tahan terhadap berbagai jenis penyakit utama.',
|
|
'date' => date('d M Y', strtotime('-14 days')),
|
|
'source' => 'Litbang Pertanian',
|
|
'image' => 'https://images.unsplash.com/photo-1530836369250-ef72a3f5cda8?w=600&q=80',
|
|
],
|
|
];
|
|
}
|
|
} |