From bf08bdc026889e69f667bdf8ab423f2e76f9e0b9 Mon Sep 17 00:00:00 2001 From: Supan Adit Pratama Date: Wed, 24 Jun 2020 00:45:04 +0700 Subject: [PATCH] Todo model and migration --- app/Http/Controllers/TodoController.php | 5 +++ app/Todo.php | 13 +++++++ app/TodoItem.php | 13 +++++++ .../2020_06_23_170808_create_todos_table.php | 39 +++++++++++++++++++ ...0_06_23_170816_create_todo_items_table.php | 38 ++++++++++++++++++ resources/views/home.blade.php | 6 +-- 6 files changed, 111 insertions(+), 3 deletions(-) create mode 100644 app/Todo.php create mode 100644 app/TodoItem.php create mode 100644 database/migrations/2020_06_23_170808_create_todos_table.php create mode 100644 database/migrations/2020_06_23_170816_create_todo_items_table.php diff --git a/app/Http/Controllers/TodoController.php b/app/Http/Controllers/TodoController.php index 7114465..d7475ea 100755 --- a/app/Http/Controllers/TodoController.php +++ b/app/Http/Controllers/TodoController.php @@ -10,4 +10,9 @@ class TodoController extends Controller { return view('home'); } + + public function createTodo() + { + + } } diff --git a/app/Todo.php b/app/Todo.php new file mode 100644 index 0000000..96bd887 --- /dev/null +++ b/app/Todo.php @@ -0,0 +1,13 @@ +hasMany('App\TodoItem'); + } +} diff --git a/app/TodoItem.php b/app/TodoItem.php new file mode 100644 index 0000000..d70cda6 --- /dev/null +++ b/app/TodoItem.php @@ -0,0 +1,13 @@ +hasOne('App\Todo'); + } +} diff --git a/database/migrations/2020_06_23_170808_create_todos_table.php b/database/migrations/2020_06_23_170808_create_todos_table.php new file mode 100644 index 0000000..b120ed8 --- /dev/null +++ b/database/migrations/2020_06_23_170808_create_todos_table.php @@ -0,0 +1,39 @@ +id(); + $table->timestamps(); + + $table->string("name"); + $table->text("Description"); + + $table->unsignedBigInteger('user_id')->default(false); + }); + Schema::table('todos', function (Blueprint $table) { + $table->foreign('user_id')->references('id')->on('users'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('todos'); + } +} diff --git a/database/migrations/2020_06_23_170816_create_todo_items_table.php b/database/migrations/2020_06_23_170816_create_todo_items_table.php new file mode 100644 index 0000000..5dd97c8 --- /dev/null +++ b/database/migrations/2020_06_23_170816_create_todo_items_table.php @@ -0,0 +1,38 @@ +id(); + $table->timestamps(); + + $table->unsignedBigInteger('todo_id'); + $table->string('name'); + $table->boolean('complete')->default(false); + }); + Schema::table('todo_items', function (Blueprint $table) { + $table->foreign('todo_id')->references('id')->on('todos'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('todo_items'); + } +} diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php index 636c25c..5d48a24 100755 --- a/resources/views/home.blade.php +++ b/resources/views/home.blade.php @@ -10,7 +10,7 @@ @section('top-button') @endsection @@ -76,8 +76,8 @@ return false; } - // CTRL + N - if (e.shiftKey && e.which === 78) { + // ALT + N + if (e.altKey && e.which === 78) { $("#modal-default").modal('show'); return false; }