get(); return view('single-optins.index', compact('brands')); } public function filter($texte, $brandId = null) { if ($brandId !== null) { $customers = SingleOptin::where([['email', 'like', '%' . $texte . '%'], ['brand_id', $brandId]])->get(); } else { $customers = SingleOptin::where('email', 'like', '%' . $texte . '%')->get(); } return response()->json($customers); } public function delete($id) { // TODO : Gestion avec les stats $optin = SingleOptin::find($id); if ($optin) { $optin->delete(); } return new StatusResource(['status' => "OK"]); } }