0% found this document useful (0 votes)
9 views2 pages

TP 2

Tp 2 programmation

Uploaded by

klmaroua5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views2 pages

TP 2

Tp 2 programmation

Uploaded by

klmaroua5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

1/ php artisan make:migration create_clients_table

public function up()


{
Schema::create('clients', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->timestamps();
});
}
2/Client.php
php artisan make:model Client

class Client extends Model


{
protected $fillable = ['name'];
}

3/php artisan make:seeder ClientsSeeder

ClientsSeeder.php
public function run()
{
Client::factory(10)->create(); // Crée 10 clients de test
}

4/php artisan migrate


php artisan db:seed --class=ClientsSeeder

5/php artisan make:model Produit


php artisan make:model Commande
php artisan make:model DetailsCommande

6/ php artisan make:controller CommandeController


7/ CommandeController.php
public function index()
{
$commandes = Commande::paginate(10);
return view('commandes.index', compact('commandes'));
}

8/Route::get('/commandes', 'CommandeController@index');

9/ @foreach($commandes as $commande)
<!-- Afficher les détails de la commande ici -->
@endforeach

{{ $commandes->links() }} <!-- Pour la pagination -->


10/ <form method="POST" action="{{ route('commandes.store') }}">
@csrf
<button type="submit">Ajouter Commande</button>
</form>

11/ <form method="POST" action="{{ route('commandes.update', $commande->id) }}">


@csrf
@method('PUT')
<button type="submit">Modifier Commande</button>
</form>
12/ <form method="POST" action="{{ route('commandes.destroy', $commande->id) }}">
@csrf
@method('DELETE')
<button type="submit">Confirmer Suppression</button>
</form>

13/public function store(Request $request)


{
$validatedData = $request->validate([
'champs_requis' => 'required',

]);
}
// 14
public function details()
{
return $this->hasMany(DetailsCommande::class);
}
@foreach($commandes as $commande)
<!-- Afficher les détails de la commande -->
{{ $commande->details }}
@endforeach

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy