Skip to content

Commit

Permalink
Add chapter-3
Browse files Browse the repository at this point in the history
  • Loading branch information
suzukalight committed Jul 23, 2020
1 parent 0797a56 commit f68ad38
Show file tree
Hide file tree
Showing 8 changed files with 182 additions and 0 deletions.
10 changes: 10 additions & 0 deletions backend/app/Folder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Folder extends Model
{
//
}
18 changes: 18 additions & 0 deletions backend/app/Http/Controllers/TaskController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace App\Http\Controllers;

use App\Folder;
use Illuminate\Http\Request;

class TaskController extends Controller
{
public function index()
{
$folders = Folder::all();

return view('tasks/index', [
'folders' => $folders,
]);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

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

class CreateFoldersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('folders', function (Blueprint $table) {
$table->increments('id');
$table->string('title', 20);
$table->timestamps();
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('folders');
}
}
26 changes: 26 additions & 0 deletions backend/database/seeds/FoldersTableSeeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use Carbon\Carbon;

class FolderTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$titles = ['プライベート', '仕事', '旅行'];

foreach ($titles as $title) {
DB::table('folders')->insert([
'title' => $title,
'created_at' => Carbon::now(),
'updated_at' => Carbon::now()
]);
}
}
}
46 changes: 46 additions & 0 deletions backend/public/css/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
@import url("https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css");
@import url("https://cdnjs.cloudflare.com/ajax/libs/bootflat/2.0.4/css/bootflat.min.css");

body {
background-color: #f4f7f8;
}

.navbar {
margin: 2rem 0 2.5rem 0;
}

.my-navbar {
align-items: center;
background: #333;
display: flex;
height: 6rem;
justify-content: space-between;
padding: 0 2%;
margin-bottom: 3rem;
}

.my-navbar-brand {
font-size: 18px;
}

.my-navbar-brand,
.my-navbar-item {
color: #8c8c8c;
}

.my-navbar-brand:hover,
a.my-navbar-item:hover {
color: #ffffff;
}

.table td:nth-child(2),
.table td:nth-child(3),
.table td:nth-child(4) {
white-space: nowrap;
width: 1px;
}

.form-control[disabled],
.form-control[readonly] {
background-color: #fff;
}
46 changes: 46 additions & 0 deletions backend/resources/views/tasks/index.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<!DOCTYPE html>
<html lang="ja">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>ToDo App</title>
<link rel="stylesheet" href="/css/styles.css">
</head>

<body>
<header>
<nav class="my-navbar">
<a class="my-navbar-brand" href="/">ToDo App</a>
</nav>
</header>
<main>
<div class="container">
<div class="row">
<div class="col col-md-4">
<nav class="panel panel-default">
<div class="panel-heading">フォルダ</div>
<div class="panel-body">
<a href="#" class="btn btn-default btn-block">
フォルダを追加する
</a>
</div>
<div class="list-group">
@foreach($folders as $folder)
<a href="{{ route('tasks.index', ['id' => $folder->id]) }}" class="list-group-item">
{{ $folder->title }}
</a>
@endforeach
</div>
</nav>
</div>
<div class="column col-md-8">
<!-- ここにタスクが表示される -->
</div>
</div>
</div>
</main>
</body>

</html>
2 changes: 2 additions & 0 deletions backend/routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@
Route::get('/', function () {
return view('welcome');
});

Route::get('/folders/{id}/tasks', 'TaskController@index')->name('tasks.index');
2 changes: 2 additions & 0 deletions backend/storage/debugbar/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore

0 comments on commit f68ad38

Please sign in to comment.