TP6 et avant

This commit is contained in:
2026-10-07 16:34:12 +02:00
parent bb4ee689a1
commit e00d488df7
89 changed files with 11733 additions and 0 deletions
@@ -0,0 +1,89 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\Client;
use App\Http\Requests\StoreClientRequest;
use App\Http\Requests\UpdateClientRequest;
class ClientController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index(Request $request)
{
$search = $request->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');
}
}