diff --git a/app/Http/Controllers/SchoolController.php b/app/Http/Controllers/SchoolController.php new file mode 100644 index 0000000..a2a12b2 --- /dev/null +++ b/app/Http/Controllers/SchoolController.php @@ -0,0 +1,10 @@ +first_name . ' ' . $this->last_name; } + + public function school(): BelongsTo + { + return $this->belongsTo(School::class); + } } diff --git a/database/factories/SchoolFactory.php b/database/factories/SchoolFactory.php new file mode 100644 index 0000000..20a3631 --- /dev/null +++ b/database/factories/SchoolFactory.php @@ -0,0 +1,23 @@ + + */ +class SchoolFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + // + ]; + } +} diff --git a/database/migrations/0001_01_01_000000_create_users_table.php b/database/migrations/0001_01_01_000000_create_users_table.php index 8bf67b9..da23e33 100644 --- a/database/migrations/0001_01_01_000000_create_users_table.php +++ b/database/migrations/0001_01_01_000000_create_users_table.php @@ -1,5 +1,6 @@ id(); + $table->string('name'); + $table->string('address')->nullable(); + $table->string('city')->nullable(); + $table->string('state')->nullable(); + $table->integer('zip')->nullable(); + $table->timestamps(); + }); + + Schema::table('users', function(Blueprint $table) { + $table->foreignIdFor(School::class)->nullable()->after('id')->constrained()->onUpdate('cascade')->onDelete('set null'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('schools'); + } +}; diff --git a/database/seeders/SchoolSeeder.php b/database/seeders/SchoolSeeder.php new file mode 100644 index 0000000..cb422f8 --- /dev/null +++ b/database/seeders/SchoolSeeder.php @@ -0,0 +1,17 @@ +