2025_03_08_182150_create_employees.php 806 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. use Illuminate\Database\Migrations\Migration;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Support\Facades\Schema;
  5. return new class extends Migration
  6. {
  7. /**
  8. * Run the migrations.
  9. */
  10. public function up(): void
  11. {
  12. Schema::create('employees', function (Blueprint $table) {
  13. $table->id();
  14. $table->string('name');
  15. $table->text('email')->unique();
  16. $table->string('position');
  17. $table->unsignedBigInteger('office_id');
  18. $table->timestamps();
  19. $table->foreign('office_id')->references('id')->on('offices')->onDelete('cascade');
  20. });
  21. }
  22. /**
  23. * Reverse the migrations.
  24. */
  25. public function down(): void
  26. {
  27. Schema::dropIfExists('employees');
  28. }
  29. };