input('search'); $query = Client::query(); if ($search) { $query->where(function ($query) use ($search) { $query->where('name', 'like', '%' . $search . '%') ->orWhere('email', 'like', '%' . $search . '%') ->orWhere('city', 'like', '%' . $search . '%'); }); } $clients = $query ->paginate(10) ->withQueryString(); return view('clients.index', compact('clients', 'search')); } /** * Show the form for creating a new resource. */ public function create() { return view('clients.create'); } /** * Show the form for creating a new resource. */ public function store(StoreClientRequest $request) { Client::create($request->validated()); return redirect()->route('clients.index'); } /** * Display the specified resource. */ public function show(Client $client) { return view('clients.show', [ 'client' => $client ]); } /** * Show the form for editing the specified resource. */ public function edit(Client $client) { // return view('clients.edit', [ 'client' => $client ]); } /** * Update the specified resource in storage. */ public function update(UpdateClientRequest $request, Client $client) { // $client->update($request->validated()); return redirect()->route('clients.index'); } /** * Remove the specified resource from storage. */ public function destroy(Client $client) { // $client->delete(); return redirect()->route('clients.index'); } }