Skip to content

Commit

Permalink
Merge pull request #64 from andes2912/feature/perpustakaan
Browse files Browse the repository at this point in the history
Perpustakaan
  • Loading branch information
andes2912 authored May 24, 2022
2 parents 3519623 + 3fed5c2 commit 0d14101
Show file tree
Hide file tree
Showing 44 changed files with 2,446 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateAuthorsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('authors', function (Blueprint $table) {
$table->id();
$table->string('name')->unique();
$table->timestamps();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('authors');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreatePublishersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('publishers', function (Blueprint $table) {
$table->id();
$table->string('name')->unique();
$table->string('address')->nullable();
$table->string('phone')->nullable();
$table->timestamps();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('publishers');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

use Illuminate\Support\Facades\Schema;
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->id();
$table->string('name')->unique();
$table->timestamps();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('categories');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

use Illuminate\Support\Facades\Schema;
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->id();
$table->string('book_code')->unique();
$table->string('name');
$table->longText('description');
$table->string('thumbnail');
$table->foreignId('category_id');
$table->foreignId('author_id');
$table->foreignId('publisher_id');
$table->year('publication_year');
$table->string('isbn', 50);
$table->integer('stock');
$table->boolean('is_available')->default('0');
$table->timestamps();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('books');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateMembersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('members', function (Blueprint $table) {
$table->id();
$table->string('member_code')->unique();
$table->foreignId('user_id')->unique();
$table->string('name');
$table->boolean('is_active')->default(0);
$table->timestamps();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('members');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateBorrowingsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('borrowings', function (Blueprint $table) {
$table->id();
$table->string('borrow_code')->unique();
$table->foreignId('member_id');
$table->foreignId('book_id');
$table->date('borrow_date');
$table->date('return_date');
$table->date('lateness')->nullable();
$table->timestamps();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('borrowings');
}
}
13 changes: 13 additions & 0 deletions Modules/Perpustakaan/Entities/Author.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Modules\Perpustakaan\Entities;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;

class Author extends Model
{
use HasFactory;

protected $guarded = '';
}
28 changes: 28 additions & 0 deletions Modules/Perpustakaan/Entities/Book.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace Modules\Perpustakaan\Entities;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;

class Book extends Model
{
use HasFactory;

protected $guarded = '';

public function publisher()
{
return $this->belongsTo(Publisher::class,'publisher_id');
}

public function author()
{
return $this->belongsTo(Author::class,'author_id');
}

public function category()
{
return $this->belongsTo(Category::class,'category_id');
}
}
23 changes: 23 additions & 0 deletions Modules/Perpustakaan/Entities/Borrowing.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace Modules\Perpustakaan\Entities;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;

class Borrowing extends Model
{
use HasFactory;

protected $guarded = '';

public function members()
{
return $this->hasOne(Member::class,'id','member_id');
}

public function books()
{
return $this->hasOne(Book::class,'id','book_id');
}
}
13 changes: 13 additions & 0 deletions Modules/Perpustakaan/Entities/Category.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Modules\Perpustakaan\Entities;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;

class Category extends Model
{
use HasFactory;

protected $guarded = '';
}
15 changes: 15 additions & 0 deletions Modules/Perpustakaan/Entities/Member.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Modules\Perpustakaan\Entities;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;

class Member extends Model
{
use HasFactory;

protected $guarded = '';


}
13 changes: 13 additions & 0 deletions Modules/Perpustakaan/Entities/Publisher.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Modules\Perpustakaan\Entities;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;

class Publisher extends Model
{
use HasFactory;

protected $guarded = '';
}
Loading

0 comments on commit 0d14101

Please sign in to comment.