my changes

This commit is contained in:
Arno Kaimbacher 2018-08-06 14:30:51 +02:00
parent 28301e4312
commit 8dc1f1b048
263 changed files with 36882 additions and 4453 deletions

1
database/.gitignore vendored
View file

@ -1 +1,2 @@
*.sqlite
*.txt

View file

@ -19,7 +19,7 @@ class CreateUsersTable extends Migration {
$table->string('email')->unique();
$table->string('password', 60);
$table->rememberToken();
$table->timestamps();
$table->nullableTimestamps();
});
}

View file

@ -1,33 +0,0 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateFinesTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('fines', function(Blueprint $table)
{
$table->integer('days');
$table->integer('fines');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('fines');
}
}

View file

@ -14,6 +14,7 @@ class CreatePeriodesTable extends Migration {
{
Schema::create('periodes', function(Blueprint $table)
{
$table->increments('id');
$table->integer('days');
$table->timestamps();
});

View file

@ -0,0 +1,46 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateTransactionsTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('transactions', function(Blueprint $table)
{
$table->increments('id');
$table->integer('student_id')->unsigned();
$table->foreign('student_id')->references('id')->on('students');
$table->integer('book_id')->unsigned();
$table->foreign('book_id')->references('id')->on('books');
$table->integer('borrowed_at');
$table->integer('returned_at')->default('0');
$table->integer('fines')->default('0');
$table->boolean('status')->default('0');
$table->timestamps();
});
// Schema::table('transactions', function($table) {
// $table->foreign('student_id')->references('id')->on('students');
// });
// Schema::table('transactions', function($table) {
// $table->foreign('book_id')->references('id')->on('books');
// });
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('transactions');
}
}

View file

@ -0,0 +1,41 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateBooksTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('books', function(Blueprint $table)
{
$table->increments('id');
$table->string('title');
$table->string('author');
$table->integer('year');
$table->integer('stock');
$table->integer('category_id')->unsigned();
$table->foreign('category_id')->references('id')->on('categories');
$table->integer('shelf_id')->unsigned();
$table->foreign('shelf_id')->references('id')->on('shelves');
$table->integer('year_id')->default('0');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('books');
}
}

View file

@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateCollectionsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('collections', function (Blueprint $table) {
$table->increments('id');
$table->string('number', 255)->nullable();
$table->string('name', 255)->nullable();
$table->string('oai_subset', 255)->nullable();
$table->integer('parent_id')->unsigned()->nullable();
$table->foreign('parent_id')->references('id')->on('collections')->onDelete('cascade');
$table->boolean('visible')->default('1');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('collections');
}
}

View file

@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateDocumentsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('documents', function (Blueprint $table) {
$table->increments('id');
$table->string('publication_state', 100)->default('draft');;
$table->boolean('belongs_to_bibliography')->default('0');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('documents');
}
}

View file

@ -0,0 +1,43 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateLinkDocumentsCollections extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('link_documents_collections', function (Blueprint $table) {
// $table->increments('id');
$table->unsignedInteger('collection_id')->nullable()->index();
$table->foreign('collection_id')
->references('id')->on('collections')
->onDelete('set null');
//->onDelete('cascade');
$table->unsignedInteger('document_id')->nullable()->index();
$table->foreign('document_id')
->references('id')->on('documents')
->onDelete('set null');
//->onDelete('cascade');
$table->primary(['collection_id', 'document_id']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('link_documents_collections');
}
}

View file

@ -0,0 +1,59 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateStudentsTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('persons', function(Blueprint $table)
{
$table->increments('id');
$table->string('name');
$table->integer('registered_at');
$table->boolean('status')->default('1');
$table->timestamps();
});
Schema::create('link_documents_persons', function (Blueprint $table) {
// $table->increments('id');
$table->unsignedInteger('person_id')->index('ix_fk_link_documents_persons_persons');
$table->foreign('person_id', 'fk_link_documents_persons_persons')
->references('id')->on('persons')
->onDelete('no action')->onUpdate('no action');//detach the relation via code
$table->unsignedInteger('document_id')->index('ix_fk_link_persons_documents_documents');
$table->foreign('document_id','fk_link_persons_documents_documents')
->references('id')->on('documents')
->onDelete('cascade')->onUpdate('cascade');
$table
->enum('role', ['advisor', 'author', 'contributor', 'editor', 'referee', 'other', 'translator', 'submitter'])
->default('author');
$table->primary(['person_id', 'document_id', 'role']);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('persons');
Schema::drop('link_persons_documents');
}
}

View file

@ -0,0 +1,91 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreatePermissionTables extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
$tableNames = config('permission.table_names');
Schema::create($tableNames['permissions'], function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('guard_name');
$table->timestamps();
});
Schema::create($tableNames['roles'], function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('guard_name');
$table->timestamps();
});
Schema::create($tableNames['model_has_permissions'], function (Blueprint $table) use ($tableNames) {
$table->unsignedInteger('permission_id');
$table->morphs('model');
$table->foreign('permission_id')
->references('id')
->on($tableNames['permissions'])
->onDelete('cascade');
$table->primary(['permission_id', 'model_id', 'model_type'], 'model_has_permissions_permission_model_type_primary');
});
Schema::create($tableNames['model_has_roles'], function (Blueprint $table) use ($tableNames) {
$table->unsignedInteger('role_id');
$table->morphs('model');
$table->foreign('role_id')
->references('id')
->on($tableNames['roles'])
->onDelete('cascade');
$table->primary(['role_id', 'model_id', 'model_type']);
});
Schema::create($tableNames['role_has_permissions'], function (Blueprint $table) use ($tableNames) {
$table->unsignedInteger('permission_id');
$table->unsignedInteger('role_id');
$table->foreign('permission_id')
->references('id')
->on($tableNames['permissions'])
->onDelete('cascade');
$table->foreign('role_id')
->references('id')
->on($tableNames['roles'])
->onDelete('cascade');
$table->primary(['permission_id', 'role_id']);
app('cache')->forget('spatie.permission.cache');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
$tableNames = config('permission.table_names');
Schema::drop($tableNames['role_has_permissions']);
Schema::drop($tableNames['model_has_roles']);
Schema::drop($tableNames['model_has_permissions']);
Schema::drop($tableNames['roles']);
Schema::drop($tableNames['permissions']);
}
}

View file

@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateCategoriesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('categories', function (Blueprint $table) {
$table->increments('id');
$table->string('category');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('categories');
}
}

View file

@ -0,0 +1,39 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateBooksTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('books', function (Blueprint $table) {
$table->increments('id');
$table->string('title');
$table->string('author');
$table->integer('year');
$table->integer('stock');
$table->integer('category_id')->unsigned();
$table->foreign('category_id')->references('id')->on('categories');
//$table->integer('shelf_id')->unsigned();
//$table->foreign('shelf_id');//->references('id')->on('shelves');
$table->integer('year_id')->default('0');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('books');
}
}

View file

@ -0,0 +1,33 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateDocumentsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('documents', function (Blueprint $table) {
$table->increments('id');
$table->string('type', 100);
$table->string('publication_state', 100)->default('draft');;
$table->boolean('belongs_to_bibliography')->default('0');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('documents');
}
}

View file

@ -12,9 +12,353 @@ class DatabaseSeeder extends Seeder {
*/
public function run()
{
Model::unguard();
// Model::unguard();
// $this->call('UserTableSeeder');
// DB::table('users')->insert([
// 'name' => str_random(10),
// 'email' => str_random(10).'@gmail.com',
// 'password' => bcrypt('secret'),
// ]);
$this->call('StudentTableSeeder');
$this->call('CategoryTableSeeder');
$this->call('ShelfTableSeeder');
$this->call('BookTableSeeder');
$this->call('PeriodeTableSeeder');
$this->call('UserTableSeeder');
$this->call('CollectionTableSeeder');
$this->call('DocumentTableSeeder');
$this->command->info('User table seeded!');
}
}
class UserTableSeeder extends Seeder {
public function run()
{
// DB::table('users')->delete();
// User::create([
// 'name' => str_random(10),
// 'email' => 'foo@gmail.com',
// 'password' => bcrypt('secret')
// ]);
DB::table('users')->insert([
[
'name' => "user1",
'email' => "user1".'@gmail.com',
'password' => bcrypt('secret')
],
[
'name' => "admin",
'email' => 'arno.kaimbacher@hotmail.de',
'password' => bcrypt('admin007')
]
]);
}
}
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',
'created_at' => '2015-06-09 02:59:49',
'updated_at' => '2015-06-10 08:14:27'
]);
}
}
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 BookTableSeeder extends Seeder {
public function run()
{
// DB::table('users')->delete();
// User::create([
// 'name' => str_random(10),
// 'email' => 'foo@gmail.com',
// 'password' => bcrypt('secret')
// ]);
DB::table('books')->insert([
[
// 'id' => '1',
'title' => 'Laravel 5',
'author' => 'Arno Kaimbacher',
'year' => '2017',
'stock' => '9',
'category_id' => '4',
'shelf_id' => '1',
'created_at' => '2015-06-09 00:17:51',
'updated_at' => '2015-06-09 01:01:36',
'year_id' => '0'
],
[
// 'id' => '2',
'title' => 'Angular.Js',
'author' => 'Mark Zuckerberg',
'year' => '2014',
'stock' => '5',
'category_id' => '4',
'shelf_id' => '3',
'created_at' => '2015-06-09 00:17:51',
'updated_at' => '2015-06-09 01:01:36',
'year_id' => '0'
],
[
// 'id' => '3',
'title' => 'OOP with PHP',
'author' => 'Richard Stallman',
'year' => '1999',
'stock' => '7',
'category_id' => '1',
'shelf_id' => '2',
'created_at' => '2015-06-09 00:17:51',
'updated_at' => '2015-06-09 01:01:36',
'year_id' => '0'
]
]);
}
}
class ShelfTableSeeder extends Seeder {
public function run()
{
DB::table('shelves')->insert([
[
'id' => '1',
'shelf' => 'A',
'created_at' => '2015-06-09 00:17:51',
'updated_at' => '2015-06-09 01:01:36'
],
[
'id' => '2',
'shelf' => 'B',
'created_at' => '2015-06-09 00:17:51',
'updated_at' => '2015-06-09 01:01:36'
],
[
'id' => '3',
'shelf' => 'C',
'created_at' => '2015-06-09 00:17:51',
'updated_at' => '2015-06-09 01:01:36'
],
[
'id' => '4',
'shelf' => 'D',
'created_at' => '2015-06-09 00:17:51',
'updated_at' => '2015-06-09 01:01:36'
],
[
'id' => '5',
'shelf' => 'E',
'created_at' => '2015-06-09 00:17:51',
'updated_at' => '2015-06-09 01:01:36'
]
]);
}
}
class StudentTableSeeder extends Seeder {
public function run()
{
DB::table('students')->insert([
[
'id' => '1',
'name' => 'Arno Kaimbacher',
'registered_at' => '1432080000',
'borrow' => '1',
'status' => '1',
'created_at' => '2015-06-09 00:17:51',
'updated_at' => '2015-06-09 01:01:36'
],
[
'id' => '2',
'name' => 'Chelsea Islan',
'registered_at' => '1433948676',
'borrow' => '1',
'status' => '1',
'created_at' => '2015-06-09 00:17:51',
'updated_at' => '2015-06-09 01:01:36'
],
[
'id' => '3',
'name' => 'John Mayer',
'registered_at' => '1434734048',
'borrow' => '0',
'status' => '1',
'created_at' => '2015-06-09 00:17:51',
'updated_at' => '2015-06-09 01:01:36'
],
[
'id' => '4',
'name' => 'Emma Watson',
'registered_at' => '1434734067',
'borrow' => '1',
'status' => '1',
'created_at' => '2015-06-09 00:17:51',
'updated_at' => '2015-06-09 01:01:36'
],
[
'id' => '5',
'name' => 'Scarlet Johansson',
'registered_at' => '1434734082',
'borrow' => '0',
'status' => '1',
'created_at' => '2015-06-09 00:17:51',
'updated_at' => '2015-06-09 01:01:36'
],
]);
}
}
class CollectionTableSeeder extends Seeder {
public function run()
{
// DB::table('users')->delete();
// User::create([
// 'name' => str_random(10),
// 'email' => 'foo@gmail.com',
// 'password' => bcrypt('secret')
// ]);
DB::table('collections')->insert([
[
'id' => '0',
'number' => null,
'name' => 'first collection',
'parent_id' => null,
'created_at' => new DateTime(),
'updated_at' => new DateTime()
],
[
'id' => '1',
'number' => '0',
'name' => 'Informatik, Informationswissenschaft, allgemeine Werke',
'parent_id' => '0',
'created_at' => '2015-06-09 00:17:51',
'updated_at' => '2015-06-09 01:01:36'
],
[
'id' => '2',
'number' => '1',
'name' => 'Philosophie und Psychologie',
'parent_id' => '0',
'created_at' => '2015-06-09 01:07:41',
'updated_at' => '2015-06-09 01:07:41'
],
[
'id' => '3',
'number' => '2',
'name' => 'Religion',
'parent_id' => '0',
'created_at' => '2015-06-09 01:07:50',
'updated_at' => '2015-06-09 01:07:50'
],
[
'id' => '4',
'number' => '3',
'name' => 'Sozialwissenschaften',
'parent_id' => '0',
'created_at' => '2015-06-09 01:07:50',
'updated_at' => '2015-06-09 01:07:50'
]
]);
}
}
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'
]
]);
}
}