Skip to content
This repository was archived by the owner on Feb 20, 2024. It is now read-only.

Commit

Permalink
feat: 加入歷史日誌
Browse files Browse the repository at this point in the history
  • Loading branch information
flamelin committed Dec 4, 2016
1 parent 6c0bf42 commit 717744f
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 4 deletions.
3 changes: 2 additions & 1 deletion app/Http/Controllers/LogsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ class LogsController extends Controller {
* @return \Illuminate\Http\Response
*/
public function index() {
//
$logs = Log::whereUserId(auth::user()->id)->orderBy('id', 'desc')->paginate(20);
return view('logs.index', compact('logs'));
}

/**
Expand Down
3 changes: 2 additions & 1 deletion resources/views/layouts/app.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
<div class="collapse navbar-collapse" id="app-navbar-collapse">
<!-- Left Side Of Navbar -->
<ul class="nav navbar-nav">
&nbsp;
<li><a href="{{ url('/log/create') }}">新增</a></li>
<li><a href="{{ url('/log') }}">歷史日誌</a></li>
</ul>

<!-- Right Side Of Navbar -->
Expand Down
40 changes: 40 additions & 0 deletions resources/views/logs/index.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
@extends('layouts.app')
@section('content')

<div class="container col-md-8 col-md-offset-2">
<div class="panel panel-primary">
<div class="panel-heading">
<h4>歷史日誌</h4>
</div>
@if ($logs->isEmpty())
<p> There is no log.</p>
@else
<table class="table">
<thead>
<tr>
<th>ID</th>
<th>日期</th>
<th>完成</th>
<th>明日</th>

</tr>
</thead>
<tbody>
@foreach($logs as $log)
<tr>
<td>{{ $log->id }}</td>
<td>{{ $log->date }}</td>
<td>{!! nl2br($log->done) !!}</td>
<td>{!! nl2br($log->future) !!}</td>
</tr>
@endforeach
</tbody>
</table>
<div class="text-center">
{{ $logs->links() }}
</div>
@endif
</div>
</div>

@endsection
3 changes: 1 addition & 2 deletions routes/web.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?php

Route::resource('log', 'LogsController');

Route::group(array('middleware' => 'auth'), function () {
Route::resource('log', 'LogsController');
Route::get('/', 'LogsController@create');
});

Expand Down

0 comments on commit 717744f

Please sign in to comment.