created FilamentCount per Manufacturer

This commit is contained in:
2025-03-10 22:39:15 +01:00
parent 9cbcddcb6b
commit c4d7410719
8 changed files with 81 additions and 58 deletions
@@ -19,6 +19,15 @@ class ManufacturerController extends Controller
return view('manufacturers.index', compact('manufacturers', 'filamentcount'));
}
public static function refresh()
{
foreach (Manufacturer::all() as $manufacturer) {
$manufacturer->filament_count = Filament::all()->where('manufacturer_id', $manufacturer->id)->count();
$manufacturer->save();
}
return redirect()->route('manufacturers.index')->with('success', 'Manufacturer count refreshed successfully.');
}
/**
* Show the form for creating a new resource.
*/