public static function archive($title, $content, $writer_id) { $slug = PageRepository::slug($title); $page = PageRepository::getPage($title); $page->rev = $page->rev + 1; $page->title = $title; $page->slug = $slug; $page->content = $content; $page->writer_id = $writer_id; $page->save(); $history = new History(); $history->pages_page_id = $page->id; $history->rev = $page->rev; $history->title = $page->title; $history->slug = $page->slug; $history->content = $page->content; $history->writer_id = $page->writer_id; $history->created_at = $page->updated_at; $history->updated_at = $page->updated_at; $history->save(); return $page; }
<?php use NineCells\Pages\Models\History; $hs = History::orderBy('id', 'desc')->paginate(10); ?> <table class="table table-bordered"> <thead> <tr> <th>제목</th> <th>변경</th> <th>변경한 사람</th> </tr> </thead> <tbody> @foreach ( $hs as $h ) <tr> <td><a href="/wiki/{{ $h->slug }}/{{ $h->rev }}">{{ $h->title }}</a></td> <td>{{ $h->created_at->diffForHumans() }}</td> <td><a href="/members/{{ $h->writer_id }}">{{ $h->writer->name }}</a></td> </tr> @endforeach </tbody> </table> {!! $hs->links() !!}