feat: Multiple Systems

This commit is contained in:
2024-03-18 01:26:54 +01:00
parent 22ea1930c4
commit 12d8f3913c
29 changed files with 2556 additions and 90 deletions

View File

@@ -17,6 +17,7 @@ return new class extends Migration
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->integer('total_votes')->default(2);
$table->rememberToken();
$table->timestamps();
});

View File

@@ -0,0 +1,37 @@
<?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('book_recommendations', function (Blueprint $table) {
$table->id();
$table->string('book_name');
$table->string('author');
$table->text('description')->nullable();
$table->string('isbn')->unique();
$table->integer('pages')->unsigned();
$table->string('cover_image')->nullable();
$table->unsignedBigInteger('recommended_by');
$table->enum('status', ['PENDING', 'COMPLETED', 'REJECTED','ACTIVE'])->default('PENDING');
$table->timestamps();
$table->foreign('recommended_by')->references('id')->on('users')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('book_recommendations');
}
};

View File

@@ -0,0 +1,29 @@
<?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('votes', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->onDelete('cascade');
$table->foreignId('book_recommendation_id')->constrained()->onDelete('cascade');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('votes');
}
};

View File

@@ -0,0 +1,29 @@
<?php
namespace Database\Seeders;
use App\Models\BookRecommendation;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class BookRecommendationsTableSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
// Let's say we want to create 50 fake book recommendations
for ($i = 0; $i < 50; $i++) {
BookRecommendation::create([
'book_name' => fake()->sentence($nbWords = 3, $variableNbWords = true),
'author' => fake()->name,
'description' => fake()->paragraph($nbSentences = 3, $variableNbSentences = true),
'isbn' => fake()->isbn13(),
'pages' => fake()->numberBetween($min = 100, $max = 1000),
'recommended_by' => 1, // Adjust the range as necessary
'cover_image' => null, // You could also simulate image paths if needed
]);
}
}
}

View File

@@ -35,5 +35,7 @@ class DatabaseSeeder extends Seeder
$user->save(['timestamps' => false]);
$user->assignRole($role1);
$this->call(BookRecommendationsTableSeeder::class);
}
}