diff --git a/docs/ERD_V-1_1.svg b/docs/ERD_V-1_1.svg
deleted file mode 100644
index db8a6b0..0000000
--- a/docs/ERD_V-1_1.svg
+++ /dev/null
@@ -1,5 +0,0 @@
-
\ No newline at end of file
diff --git a/docs/ERD_V-1_2.svg b/docs/ERD_V-1_2.svg
new file mode 100644
index 0000000..dc8c015
--- /dev/null
+++ b/docs/ERD_V-1_2.svg
@@ -0,0 +1,12 @@
+11*111111111111*1*11111111111111111111111111useridintegerfirst_namevarcharlast_namevarcharemailvarcharresidencevarcharzip_codevarcharhouse_numbervarcharmodified_kindvarchar(1)modified_userintegercreated_attimestampupdated_attimstamplibrary_passidintegeruser_idintegerbarcodestringactivebooleanmodified_kindvarchar(1)modified_userintegercreated_attimestampupdated_attimstampitemidintegeridentifiervarchartypevarcharnamevarchardescriptiontextauthor_idintegercategoryintegerisbnvarcharratingintegerborrowing_timedatetimemodified_kindvarchar(1)modified_userintegercreated_attimestampupdated_attimstampitem_typeidintegertypevarcharmodified_kindvarchar(1)modified_userintegercreated_attimestampupdated_attimstampitem_categoryidintegercategorystringmodified_kindvarchar(1)modified_userintegercreated_attimestampupdated_attimestampitem_age_ratingidintegerratingvarcharmodified_kindvarchar(1)modified_userintegercreated_attimestampupdated_attimestampitem_imageidintegeritem_idintegerfilenamevarcharpathvarcharmodified_kindvarchar(1)modified_userintegercreated_attimestampupdated_attimestampgrantsidintegeruser_idintegeritem_idintegerborrow_datetimestamphand_in_datetimestampmodified_kindvarchar(1)modified_userintegercreated_attimestampupdated_attimstampreservationsidintegeruser_idintegeritem_idintegerexpire_datetimestampmodified_kindvarchar(1)modified_userintegercreated_attimestampupdated_attimstampfineidintegergrant_idintegeramountdoublemodified_kindvarchar(1)modified_userintegercreated_attimestampupdated_attimstamppayment_transactionidintegerfine_idintegerpaiddoublemodified_kindvarchar(1)modified_userintegercreated_attimestampupdated_attimstampauthoridintegernamestringmodified_kindvarchar(1)modified_userintegercreated_attimestampupdated_attimstamp
\ No newline at end of file
diff --git a/src/app/Http/Controllers/AuthorController.php b/src/app/Http/Controllers/AuthorController.php
new file mode 100644
index 0000000..764acfb
--- /dev/null
+++ b/src/app/Http/Controllers/AuthorController.php
@@ -0,0 +1,10 @@
+importOpenLibrary();
return Inertia::render('index');
}
}
diff --git a/src/app/Models/Author.php b/src/app/Models/Author.php
new file mode 100644
index 0000000..c686aab
--- /dev/null
+++ b/src/app/Models/Author.php
@@ -0,0 +1,12 @@
+ $this->generateValidItemIdentifier(),
- 'type' => 'book',
- 'name' => $book['title'],
- 'description' => "Dit boek is geschreven door {$book['author_name'][0]} en is uitgegeven in {$book['first_publish_year']}.",
- 'category' => 1,
- 'ISBN' => $book['isbn'][0],
- 'rating' => 1,
- 'borrowing_time' => 30,
- 'modified_kind' => 'I',
- 'modified_user' => User::where('email', 'superadmin@biblio.nl')->first()->id,
+ $authorName = !isset($book['author_name'][0]) ? $book['publisher'][0] : $book['author_name'][0];
+
+ if (!Author::where('name', $authorName)->exists()) {
+ $author = Author::create([
+ 'name' => $authorName,
+ 'modified_kind' => 'I',
+ 'modified_user' => User::where('email', 'superadmin@biblio.nl')->first()->id,
]);
+ } else {
+ $author = Author::where('name', $authorName)->first();
+ }
+
+ Item::create([
+ 'identifier' => $this->generateValidItemIdentifier(),
+ 'type' => 'book',
+ 'name' => $book['title'],
+ 'author_id' => $author->id,
+ 'description' => "Dit boek is geschreven door {$authorName} en is uitgegeven in {$book['first_publish_year']}.",
+ 'category' => 1,
+ 'ISBN' => $book['isbn'][0] ?? "N/A",
+ 'rating' => 1,
+ 'borrowing_time' => 30,
+ 'modified_kind' => 'I',
+ 'modified_user' => User::where('email', 'superadmin@biblio.nl')->first()->id,
+ ]);
}
private function getData($offset)
{
- $baseUrl = "https://openlibrary.org/search.json?q=language%3Adut&sort=new&lang=nl&offset=" . $offset;
- $curl = curl_init();
- curl_setopt($curl, CURLOPT_URL, $baseUrl);
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
- $response = curl_exec($curl);
- curl_close($curl);
-
- $response = json_decode($response, true);
- return $response['docs'];
+ $baseUrl = "https://openlibrary.org/search.json?q=language%3Adut&sort=new&lang=nl&offset=" . $offset;
+
+ $curl = curl_init();
+ curl_setopt($curl, CURLOPT_URL, $baseUrl);
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
+
+ $response = curl_exec($curl);
+
+ curl_close($curl);
+
+ $response = json_decode($response, true);
+
+ return $response['docs'];
}
}
diff --git a/src/database/migrations/2024_01_17_101551_create_authors_table.php b/src/database/migrations/2024_01_17_101551_create_authors_table.php
new file mode 100644
index 0000000..545fa55
--- /dev/null
+++ b/src/database/migrations/2024_01_17_101551_create_authors_table.php
@@ -0,0 +1,37 @@
+id();
+ $table->string('name');
+ $table->char('modified_kind' ,1)->default('I');
+ $table->unsignedBigInteger('modified_user');
+ $table->foreign('modified_user')->references('id')->on('users')->onDelete("cascade");
+ $table->timestamps();
+ });
+
+ Schema::table('items', function (Blueprint $table) {
+ $table->unsignedBigInteger('author_id')->nullable()->after('name');
+ $table->foreign('author_id')->references('id')->on('authors');
+ $table->dropColumn('author');
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ Schema::dropIfExists('authors');
+ }
+};