From e06238e653eaa43a98f877fa8c1a989a2ee4478d Mon Sep 17 00:00:00 2001 From: Eric WAGNER <ericwagner.contact@gmail.com> Date: Fri, 20 Oct 2023 08:49:49 +0200 Subject: [PATCH] php artisan make:model Student --migration --- app/Models/Student.php | 13 ++++++++ ...023_10_20_064820_create_students_table.php | 30 +++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 app/Models/Student.php create mode 100644 database/migrations/2023_10_20_064820_create_students_table.php diff --git a/app/Models/Student.php b/app/Models/Student.php new file mode 100644 index 0000000..0a39863 --- /dev/null +++ b/app/Models/Student.php @@ -0,0 +1,13 @@ +<?php + +namespace App\Models; + +use Illuminate\Database\Eloquent\Factories\HasFactory; +use Illuminate\Database\Eloquent\Model; + +class Student extends Model +{ + use HasFactory; + + protected $fillable = ['firstname', 'lastname', 'email']; +} diff --git a/database/migrations/2023_10_20_064820_create_students_table.php b/database/migrations/2023_10_20_064820_create_students_table.php new file mode 100644 index 0000000..28c9136 --- /dev/null +++ b/database/migrations/2023_10_20_064820_create_students_table.php @@ -0,0 +1,30 @@ +<?php + +use Illuminate\Database\Migrations\Migration; +use Illuminate\Database\Schema\Blueprint; +use Illuminate\Support\Facades\Schema; + +return new class extends Migration +{ + /** + * Run the migrations. + */ + public function up(): void + { + Schema::create('students', function (Blueprint $table) { + $table->id(); + $table->timestamps(); + $table->string('firstname'); + $table->string('lastname'); + $table->string('email')->unique(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('students'); + } +}; -- GitLab