chore: stop tracking compiled blade cache

This commit is contained in:
2026-09-23 13:56:51 +07:00
parent 507fc6ccdf
commit edd2f626be
154 changed files with 1149 additions and 12046 deletions
+46 -39
View File
@@ -30,13 +30,24 @@ class CatController extends Controller
*/
public function index(Request $request): View
{
// Proteksi Akses: Read
Gate::authorize('check-access', ['cats', 'read']);
$now = now();
$listScope = $request->get('list_scope', 'active');
if (!in_array($listScope, ['active', 'adopted', 'external_parent', 'all'], true)) {
$listScope = 'active';
}
$query = Cat::query()->with(['pic:id,name', 'sire', 'dam', 'registrations.association']);
// 1. PENCARIAN GLOBAL
if ($listScope === 'active') {
$query->activeInCattery();
} elseif ($listScope === 'adopted') {
$query->adopted();
} elseif ($listScope === 'external_parent') {
$query->externalParents();
}
if ($request->filled('search')) {
$search = $request->search;
$query->where(function($q) use ($search) {
@@ -46,22 +57,18 @@ class CatController extends Controller
->orWhere('pedigree', 'like', "%{$search}%")
->orWhere('kode_ems', 'like', "%{$search}%")
->orWhere('lokasi_kandang', 'like', "%{$search}%")
->orWhereHas('pic', function($sub) use ($search) {
$sub->where('name', 'like', "%{$search}%");
});
->orWhereHas('pic', fn($sub) => $sub->where('name', 'like', "%{$search}%"));
});
}
// 2. FILTER OVERDUE (Link dari Dashboard)
if ($request->filled('filter_overdue')) {
$filter = $request->get('filter_overdue');
$query->where(function($q) use ($filter, $now) {
if ($filter === 'vaccine') {
$q->whereNotNull('jadwal_vaksin')->where('jadwal_vaksin', '<', $now);
} elseif ($filter === 'flea' || $filter === 'obat_kutu') {
} elseif (in_array($filter, ['flea', 'obat_kutu'], true)) {
$q->whereNotNull('jadwal_obat_kutu')->where('jadwal_obat_kutu', '<', $now);
} elseif ($filter === 'deworming' || $filter === 'obat_cacing') {
} elseif (in_array($filter, ['deworming', 'obat_cacing'], true)) {
$q->whereNotNull('jadwal_obat_cacing')->where('jadwal_obat_cacing', '<', $now);
} elseif ($filter === 'grooming') {
$q->whereNotNull('jadwal_grooming')->where('jadwal_grooming', '<', $now);
@@ -69,63 +76,47 @@ class CatController extends Controller
});
}
// --- TAMBAHAN: 2.1 FILTER KESEHATAN (Link dari Dashboard Under Treatment) ---
if ($request->get('filter_health') === 'treatment') {
// Menggunakan kolom treatment_status: 1 (Treatment), 2 (Healthy)
$query->where('treatment_status', 1);
}
// 3. FILTER STATUS & LOGIKA USIA DINAMIS
if ($request->filled('status')) {
$status = $request->status;
if (in_array(strtolower($status), ['adult', 'dewasa'])) {
// Dewasa: > 12 bulan
if (in_array(strtolower($status), ['adult', 'dewasa'], true)) {
$query->where('tanggal_lahir', '<=', $now->copy()->subMonths(12));
} elseif ($status === 'Junior') {
// Junior: 7 bulan - 12 bulan
$query->whereBetween('tanggal_lahir', [
$now->copy()->subMonths(12)->addDay(),
$now->copy()->subMonths(7)
]);
$query->whereBetween('tanggal_lahir', [$now->copy()->subMonths(12)->addDay(), $now->copy()->subMonths(7)]);
} elseif ($status === 'Kitten') {
// Kitten: < 7 bulan
$query->where('tanggal_lahir', '>', $now->copy()->subMonths(7));
} else {
$query->where('status', $status);
}
}
// 4. FILTER STANDAR (Ras & Gender)
if ($request->filled('ras')) $query->where('ras', $request->ras);
if ($request->filled('ras')) $query->where('ras', $request->ras);
if ($request->filled('gender')) $query->where('jenis_kelamin', $request->gender);
// 5. VALIDASI SORTING
$allowedSorts = ['nama_kucing', 'lokasi_kandang', 'berat_badan', 'created_at', 'pic_name'];
$sort = in_array($request->get('sort'), $allowedSorts) ? $request->get('sort') : 'created_at';
$sort = in_array($request->get('sort'), $allowedSorts, true) ? $request->get('sort') : 'created_at';
$direction = strtolower($request->get('direction')) === 'asc' ? 'asc' : 'desc';
if ($sort === 'pic_name') {
$query->leftJoin('users', 'cats.pic_id', '=', 'users.id')
->select('cats.*')
->orderBy('users.name', $direction);
$query->leftJoin('users', 'cats.pic_id', '=', 'users.id')->select('cats.*')->orderBy('users.name', $direction);
} else {
$query->orderBy("cats.$sort", $direction);
}
// 6. EKSEKUSI DENGAN PAGINASI
$cats = $query->paginate(15)->withQueryString();
// 7. STATISTIK (DIPERBAIKI: Menggunakan treatment_status)
$totalCats = Cat::count();
// Perbaikan: Tidak lagi menggunakan string search yang tidak akurat (15 vs 4)
// Sekarang langsung merujuk pada kolom treatment_status bernilai 1
$sickCats = Cat::where('treatment_status', 1)->count();
$activeCats = Cat::activeInCattery()->count();
$adoptedCats = Cat::adopted()->count();
$externalParentCats = Cat::externalParents()->count();
$sickCats = Cat::activeInCattery()->where('treatment_status', 1)->count();
$breeds = Cat::activeInCattery()->distinct()->whereNotNull('ras')->pluck('ras');
$breeds = Cat::distinct()->whereNotNull('ras')->pluck('ras');
return view('pages.cats.index', compact('cats', 'totalCats', 'sickCats', 'breeds'));
return view('pages.cats.index', compact(
'cats', 'activeCats', 'adoptedCats', 'externalParentCats', 'sickCats', 'breeds', 'listScope'
));
}
public function create(): View
@@ -169,6 +160,13 @@ class CatController extends Controller
$validated['induk_jantan_id'] = $request->induk_jantan_id;
$validated['induk_betina_id'] = $request->induk_betina_id;
$validated['pic_id'] = $request->pic_id ?? auth()->id();
$validated['cattery_status'] = $request->boolean('is_external_parent')
? 'external_parent'
: ($request->boolean('is_adopted') ? 'adopted' : 'active');
$validated['adopted_at'] = $validated['cattery_status'] === 'adopted'
? ($request->input('adopted_at') ?: now()->toDateString())
: null;
$validated['adoption_notes'] = $request->input('adoption_notes');
$cat = Cat::create($validated);
@@ -267,6 +265,13 @@ private function handleImageUpload($file): string
* Kita paksa nilainya menjadi ['NON-PED'] agar data lama di DB terhapus/terganti.
*/
$validated['registry'] = $request->input('registry', ['NON-PED']);
$validated['cattery_status'] = $request->boolean('is_external_parent')
? 'external_parent'
: ($request->boolean('is_adopted') ? 'adopted' : 'active');
$validated['adopted_at'] = $validated['cattery_status'] === 'adopted'
? ($request->input('adopted_at') ?: ($cat->adopted_at?->format('Y-m-d') ?? now()->toDateString()))
: null;
$validated['adoption_notes'] = $request->input('adoption_notes');
// 5. Update Data Utama
// Logika berat_badan sudah otomatis dihandle oleh Model (static::saving/updated)
@@ -449,7 +454,9 @@ private function validateCat(Request $request, $id = null)
'kode_ems' => 'nullable|string|max:50',
// Status & Lokasi
'status' => 'nullable|string|max:50',
'status' => 'nullable|string|max:50',
'adopted_at' => 'nullable|date',
'adoption_notes'=> 'nullable|string|max:1000',
'lokasi_kandang'=> 'nullable|string|max:255',
'pic_id' => 'nullable|exists:users,id',