mirror of
https://github.com/supanadit/todo.git
synced 2024-11-22 01:56:21 +00:00
Todo model and migration
This commit is contained in:
parent
e5dd77e1d7
commit
bf08bdc026
@ -10,4 +10,9 @@ class TodoController extends Controller
|
||||
{
|
||||
return view('home');
|
||||
}
|
||||
|
||||
public function createTodo()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
13
app/Todo.php
Normal file
13
app/Todo.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Todo extends Model
|
||||
{
|
||||
public function todoItems()
|
||||
{
|
||||
return $this->hasMany('App\TodoItem');
|
||||
}
|
||||
}
|
13
app/TodoItem.php
Normal file
13
app/TodoItem.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class TodoItem extends Model
|
||||
{
|
||||
public function todo()
|
||||
{
|
||||
return $this->hasOne('App\Todo');
|
||||
}
|
||||
}
|
39
database/migrations/2020_06_23_170808_create_todos_table.php
Normal file
39
database/migrations/2020_06_23_170808_create_todos_table.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateTodosTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('todos', function (Blueprint $table) {
|
||||
$table->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');
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateTodoItemsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('todo_items', function (Blueprint $table) {
|
||||
$table->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');
|
||||
}
|
||||
}
|
@ -10,7 +10,7 @@
|
||||
|
||||
@section('top-button')
|
||||
<button class="btn btn-info btn-sm" data-toggle="modal" data-target="#modal-default">
|
||||
Create Todo
|
||||
Create Directory
|
||||
</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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user