This commit is contained in:
2025-11-17 15:24:36 +01:00
parent 9e7da12f7d
commit 9c3ae47b63
61 changed files with 10933 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\Client;
class ClientController extends Controller
{
public function index() {
return Client::all(); //afficher toutes les lignes de la table clients
}
/**
* Requete Get client{id}
*/
public function show($id) { return Client::findOrFail($id); }
/**
* Requete Post Client
*/
public function store(Request $request) {
$data = $request->validate(['nom'=>'required', 'prenom'=>'required','email'=>'required|email|unique:clients','telephone'=>'nullable|regex:/^[0][0-9]{9}$/']);
return Client::create($data);
}
/**
* Requete
*/
public function update(Request $request, $id) {
$client = Client::findOrFail($id);
$client->update($request->all());
return $client;
}
/**
* Requete Destroy client{id}
*/
public function destroy($id) {
$client = Client::findOrFail($id);
$client->delete();
return response()->noContent();
}
}

View File

@@ -0,0 +1,8 @@
<?php
namespace App\Http\Controllers;
abstract class Controller
{
//
}

11
app/Models/Client.php Normal file
View File

@@ -0,0 +1,11 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class Client extends Model
{
protected $fillable = ['nom', 'prenom','email', 'telephone'];
}

48
app/Models/User.php Normal file
View File

@@ -0,0 +1,48 @@
<?php
namespace App\Models;
// use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class User extends Authenticatable
{
/** @use HasFactory<\Database\Factories\UserFactory> */
use HasFactory, Notifiable;
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
'name',
'email',
'password',
];
/**
* The attributes that should be hidden for serialization.
*
* @var list<string>
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
'email_verified_at' => 'datetime',
'password' => 'hashed',
];
}
}

View File

@@ -0,0 +1,24 @@
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*/
public function register(): void
{
//
}
/**
* Bootstrap any application services.
*/
public function boot(): void
{
//
}
}