From 4d22498e2d3245e0148f720d3f7e6ff14c75dcdd Mon Sep 17 00:00:00 2001 From: Arno Kaimbacher Date: Thu, 29 Aug 2019 17:51:13 +0200 Subject: [PATCH] added migrations for mime_types --- .../Controllers/Oai/RequestController.php | 2 +- ...9_08_29_150721_create_mime_types_table.php | 34 +++++++ database/seeds/DatabaseSeeder.php | 91 +------------------ database/seeds/MimetypeTableSeeder.php | 65 +++++++++++++ 4 files changed, 102 insertions(+), 90 deletions(-) create mode 100644 database/migrations/2019_08_29_150721_create_mime_types_table.php create mode 100644 database/seeds/MimetypeTableSeeder.php diff --git a/app/Http/Controllers/Oai/RequestController.php b/app/Http/Controllers/Oai/RequestController.php index 1a56d38..ea06835 100644 --- a/app/Http/Controllers/Oai/RequestController.php +++ b/app/Http/Controllers/Oai/RequestController.php @@ -148,7 +148,7 @@ class RequestController extends Controller $repositoryName = "RDR - Data Research Repository"; $repIdentifier = "rdr.gba.ac.at"; $sampleIdentifier = "oai:" . $repIdentifier . ":27";//$this->_configuration->getSampleIdentifier(); - $earliestDateFromDb = Dataset::earliestPublicationDate()->get('server_date_published'); + $earliestDateFromDb = optional(Dataset::earliestPublicationDate())->server_date_published; // set parameters for oai-pmh.xslt $this->_proc->setParameter('', 'email', $email); diff --git a/database/migrations/2019_08_29_150721_create_mime_types_table.php b/database/migrations/2019_08_29_150721_create_mime_types_table.php new file mode 100644 index 0000000..3bc4d8d --- /dev/null +++ b/database/migrations/2019_08_29_150721_create_mime_types_table.php @@ -0,0 +1,34 @@ +increments('id'); + $table->string('name', 255); + $table->string('file_extension', 255); + $table->boolean('enabled')->default(false); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('mime_types'); + } +} diff --git a/database/seeds/DatabaseSeeder.php b/database/seeds/DatabaseSeeder.php index d21468e..bc7577a 100755 --- a/database/seeds/DatabaseSeeder.php +++ b/database/seeds/DatabaseSeeder.php @@ -23,7 +23,7 @@ class DatabaseSeeder extends Seeder // $this->call('CategoryTableSeeder'); // $this->call('BookTableSeeder'); - // $this->call('PeriodeTableSeeder'); + $this->call('MimetypeTableSeeder'); $this->call('AccountsTableSeeder'); $this->call('RolesTableSeeder'); $this->call('LicencesTableSeeder'); @@ -33,67 +33,6 @@ class DatabaseSeeder extends Seeder } } - - -class PeriodeTableSeeder extends Seeder -{ - public function run() - { - // DB::table('users')->delete(); - - // User::create([ - // 'name' => str_random(10), - // 'email' => 'foo@gmail.com', - // 'password' => bcrypt('secret') - // ]); - DB::table('periodes')->insert([ - 'id' => '1', - 'days' => '100', - - ]); - } -} - -class CategoryTableSeeder extends Seeder -{ - public function run() - { - // DB::table('users')->delete(); - - // User::create([ - // 'name' => str_random(10), - // 'email' => 'foo@gmail.com', - // 'password' => bcrypt('secret') - // ]); - DB::table('categories')->insert([ - [ - // 'id' => '1', - 'category' => 'Sains', - 'created_at' => '2015-06-09 00:17:51', - 'updated_at' => '2015-06-09 01:01:36', - ], - [ - // 'id' => '2', - 'category' => 'Computer', - 'created_at' => '2015-06-09 01:07:41', - 'updated_at' => '2015-06-09 01:07:41', - ], - [ - // 'id' => '3', - 'category' => 'Life Lesson', - 'created_at' => '2015-06-09 01:07:50', - 'updated_at' => '2015-06-09 01:07:50', - ], - [ - // 'id' => '4', - 'category' => 'Fairy Tail', - 'created_at' => '2015-06-09 01:07:50', - 'updated_at' => '2015-06-09 01:07:50', - ], - ]); - } -} - class CollectionTableSeeder extends Seeder { public function run() @@ -148,30 +87,4 @@ class CollectionTableSeeder extends Seeder ], ]); } -} - -class DocumentTableSeeder extends Seeder -{ - public function run() - { - DB::table('documents')->insert([ - [ - 'id' => '0', - ], - [ - 'id' => '1', - ], - ]); - - DB::table('link_documents_collections')->insert([ - [ - 'document_id' => '0', - 'collection_id' => '1', - ], - [ - 'document_id' => '1', - 'collection_id' => '1', - ], - ]); - } -} +} \ No newline at end of file diff --git a/database/seeds/MimetypeTableSeeder.php b/database/seeds/MimetypeTableSeeder.php new file mode 100644 index 0000000..0eefec7 --- /dev/null +++ b/database/seeds/MimetypeTableSeeder.php @@ -0,0 +1,65 @@ +insert([ + [ + 'name' => 'image/jpeg', + 'file_extension' => 'jpg|jpeg|jpe', + 'enabled' =>true, + 'created_at' => Carbon::now(), + 'updated_at' => Carbon::now(), + ], + [ + 'name' => 'image/png', + 'file_extension' => 'png', + 'enabled' =>true, + 'created_at' => Carbon::now(), + 'updated_at' => Carbon::now(), + ], + [ + 'name' => 'application/pdf', + 'file_extension' => 'pdf', + 'enabled' =>true, + 'created_at' => Carbon::now(), + 'updated_at' => Carbon::now(), + ], + [ + 'name' => 'text/html', + 'file_extension' => 'htm|html', + 'enabled' =>true, + 'created_at' => Carbon::now(), + 'updated_at' => Carbon::now(), + ], + [ + 'name' => 'text/csv', + 'file_extension' => 'csv', + 'enabled' =>true, + 'created_at' => Carbon::now(), + 'updated_at' => Carbon::now(), + ], + [ + 'name' => 'text/plain', + 'file_extension' => 'txt|asc|c|cc|h|srt', + 'enabled' =>true, + 'created_at' => Carbon::now(), + 'updated_at' => Carbon::now(), + ], + [ + 'name' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + 'file_extension' => 'xlsx', + 'enabled' =>true, + 'created_at' => Carbon::now(), + 'updated_at' => Carbon::now(), + ], + ]); + } +}