From bf7ae561400fcf36f757d84b031cf2b7ba520ff5 Mon Sep 17 00:00:00 2001 From: NishaSharma14 Date: Wed, 24 Aug 2022 14:41:43 +0200 Subject: [PATCH 1/7] Citation WIP. --- .../Controllers/Admin/LicenseController.php | 2 - app/Http/Controllers/CitationController.php | 8 + app/Http/Controllers/StudyController.php | 1 + app/Http/Resources/LicenseResource.php | 1 + app/Models/Citation.php | 28 ++ ...22_08_23_143935_create_citations_table.php | 36 ++ ...4_111011_create_citation_project_table.php | 35 ++ resources/js/Pages/Public/Project/Show.vue | 6 +- resources/js/Shared/AddCitation.vue | 425 ++++++++++++++++++ 9 files changed, 539 insertions(+), 3 deletions(-) create mode 100644 app/Http/Controllers/CitationController.php create mode 100644 app/Models/Citation.php create mode 100644 database/migrations/2022_08_23_143935_create_citations_table.php create mode 100644 database/migrations/2022_08_24_111011_create_citation_project_table.php create mode 100644 resources/js/Shared/AddCitation.vue diff --git a/app/Http/Controllers/Admin/LicenseController.php b/app/Http/Controllers/Admin/LicenseController.php index a7cb568c..938852b9 100644 --- a/app/Http/Controllers/Admin/LicenseController.php +++ b/app/Http/Controllers/Admin/LicenseController.php @@ -17,8 +17,6 @@ public function index(Request $request) $licenses = Cache::rememberForever('licenses', function () { return License::select('id', 'title', 'description')->get(); }); - - // $licenses = License::select('id','title')->get(); return $licenses; } diff --git a/app/Http/Controllers/CitationController.php b/app/Http/Controllers/CitationController.php new file mode 100644 index 00000000..ca7f338e --- /dev/null +++ b/app/Http/Controllers/CitationController.php @@ -0,0 +1,8 @@ +sample; $sample->molecules()->detach([$molecule->id]); $sample = $sample->fresh(); + return $sample->molecules; } } diff --git a/app/Http/Resources/LicenseResource.php b/app/Http/Resources/LicenseResource.php index f2075ac4..b000ed97 100644 --- a/app/Http/Resources/LicenseResource.php +++ b/app/Http/Resources/LicenseResource.php @@ -22,6 +22,7 @@ public function toArray($request) 'html_url' => $this->html_url, 'permissions' => $this->permissions, 'description' => $this->description, + 'body' => $this->body, ]; } } diff --git a/app/Models/Citation.php b/app/Models/Citation.php new file mode 100644 index 00000000..5ebadd23 --- /dev/null +++ b/app/Models/Citation.php @@ -0,0 +1,28 @@ +belongsToMany(Project::class); + } +} diff --git a/database/migrations/2022_08_23_143935_create_citations_table.php b/database/migrations/2022_08_23_143935_create_citations_table.php new file mode 100644 index 00000000..080db538 --- /dev/null +++ b/database/migrations/2022_08_23_143935_create_citations_table.php @@ -0,0 +1,36 @@ +id(); + $table->string('doi'); + $table->string('title'); + $table->longText('authors'); + $table->longText('abstract'); + $table->longText('citation_text'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('citations'); + } +}; diff --git a/database/migrations/2022_08_24_111011_create_citation_project_table.php b/database/migrations/2022_08_24_111011_create_citation_project_table.php new file mode 100644 index 00000000..d8e86ddc --- /dev/null +++ b/database/migrations/2022_08_24_111011_create_citation_project_table.php @@ -0,0 +1,35 @@ +id(); + $table->foreignId('project_id'); + $table->foreignId('citation_id'); + $table->string('user')->nullable(); + $table->timestamps(); + $table->unique(['project_id', 'citation_id']); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('citation_project'); + } +}; diff --git a/resources/js/Pages/Public/Project/Show.vue b/resources/js/Pages/Public/Project/Show.vue index bd7c9fb2..11172464 100644 --- a/resources/js/Pages/Public/Project/Show.vue +++ b/resources/js/Pages/Public/Project/Show.vue @@ -66,7 +66,11 @@ user.last_name }}

-

@ {{ user.username }}

+

+ @ {{ user.username }} +

diff --git a/resources/js/Shared/AddCitation.vue b/resources/js/Shared/AddCitation.vue new file mode 100644 index 00000000..4f09ef93 --- /dev/null +++ b/resources/js/Shared/AddCitation.vue @@ -0,0 +1,425 @@ +