Refactor: responses as ActivitesAttended
This commit is contained in:
@@ -4,13 +4,13 @@ use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateResponsesTable extends Migration
|
||||
class CreateActivitiesAttendedsTable extends Migration
|
||||
{
|
||||
|
||||
// Updated Migration
|
||||
public function up()
|
||||
{
|
||||
Schema::create('responses', function (Blueprint $table) {
|
||||
Schema::create('activities_attendeds', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('title');
|
||||
$table->string('organising_institute');
|
||||
@@ -33,6 +33,6 @@ class CreateResponsesTable extends Migration
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('responses');
|
||||
Schema::dropIfExists('activities_attendeds');
|
||||
}
|
||||
}
|
||||
@@ -3,10 +3,10 @@
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use App\Models\Response;
|
||||
use App\Models\ActivitiesAttended;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class ResponsesTableSeeder extends Seeder
|
||||
class ActivitiesAttendedResponsesTableSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
@@ -33,12 +33,12 @@ class ResponsesTableSeeder extends Seeder
|
||||
$numDays = $startDate->diffInDays($endDate) ?: 1;
|
||||
|
||||
// Create the response record
|
||||
Response::create([
|
||||
ActivitiesAttended::create([
|
||||
'title' => $titles[array_rand($titles)], // Random title
|
||||
'organising_institute' => $organizingInstitutes[array_rand($organizingInstitutes)], // Random organization
|
||||
'address' => $addresses[array_rand($addresses)], // Random address
|
||||
'department_id' => rand(1, 5), // Random department ID
|
||||
'faculty_id' => rand(1, 3), // Random faculty ID
|
||||
'faculty_id' => rand(1, 2), // Random faculty ID
|
||||
'start_date' => $startDate->format('Y-m-d H:i:s'), // Start date and time
|
||||
'end_date' => $endDate->format('Y-m-d H:i:s'), // End date and time
|
||||
'num_days' => $numDays, // Number of days
|
||||
@@ -19,7 +19,7 @@ class DatabaseSeeder extends Seeder
|
||||
RoleSeeder::class,
|
||||
DepartmentSeeder::class,
|
||||
UsersTableSeeder::class,
|
||||
ResponsesTableSeeder::class,
|
||||
ActivitiesAttendedResponsesTableSeeder::class,
|
||||
]);
|
||||
|
||||
// User::factory()->create([
|
||||
|
||||
Reference in New Issue
Block a user