paginate(10); // $clients = DB::select( DB::raw("select customers.* from customers join abonnements ON customers.id= abonnements.id_customer WHERE abonnements.id in (select MAX(abonnements.id) FROM abonnements)") ); //dd($clients); return view('abonnement.clientsliste', ['clients' => $clients]); } public function detail($id) { // $abonnement=Abonnement::find($id); $abonnement = DB::table('abonnements')->where('id_customer', $id)->orderBy("created_at", 'desc')->get(); $client = Customer::find($id); return view('abonnement.abonnementslist', ['abonnements' => $abonnement, 'client' => $client]); //dd($abonnement); } public function nouveauabonnement($id) { $client = Customer::find($id); return view('abonnement.ajouterabonnement')->with('client', $client); } /** * Show the form for creating a new resource. * * @return \Illuminate\Http\Response */ public function create() { // } /** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { /****update customer****/ $customer = Customer::find($request->input('id_client')); $customer->date_debut = $request->input('date_debut'); $customer->date_fin = $request->input('date_fin'); $customer->save(); /* add abonnement */ $abonnement = new Abonnement; $abonnement->date_debut = $request->input('date_debut'); $abonnement->date_fin = $request->input('date_fin'); $abonnement->id_customer = $request->input('id_client'); if ($abonnement->save()) { Session::flash('message', 'la nouvelle abonnement a été bien ajouté'); return redirect()->route('detailsabonnemnt', ['id' => $request->input('id_client')]); } //dd($request); } public function delete($id) { $abonnement = Abonnement::find($id); if ($abonnement->delete()) { Session::flash('message', 'l Abonnement a été bien supprimé'); return redirect()->back(); } } /** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function show($id) { // } /** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { // } /** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { } /** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { // } public function shearch(Request $request) { $clients = DB::table('customers') ->where('nom', 'like', '%' . $request->input('nom') . '%')->orderBy("created_at", 'desc') ->paginate(10); //$clients = DB::table('customers')->where('nom', $request->input('nom'))->paginate(10); if (!$clients->isEmpty()) { return view('abonnement.clientsliste', ['clients' => $clients]); } else { $clients = Customer::orderBy("created_at", 'desc')->paginate(10); return view('abonnement.clientsliste', ['clients' => $clients]); } } public function searchclientabonnement(Request $request) { $customer = DB::table('customers') ->where('nom', 'like', '%' . $request->nom . '%')->orderBy("created_at", 'desc') ->paginate(10); if (!$customer->isEmpty()) { return view('customershearch.customerlistabonnement', ['clients' => $customer]); } else { $clients = Customer::orderBy("created_at", 'desc')->paginate(10); return view('customershearch.customerlistabonnement', ['clients' => $clients]); } } public function searchclientabonnementbyemail(Request $request) { $customer = DB::table('customers') ->where('email', 'like', '%' . $request->email . '%')->orderBy("created_at", 'desc') ->paginate(10); if (!$customer->isEmpty()) { return view('customershearch.customerlistabonnement', ['clients' => $customer]); } else { $clients = Customer::orderBy("created_at", 'desc')->paginate(10); return view('customershearch.customerlistabonnement', ['clients' => $clients]); } } }