Skip to content
This repository has been archived by the owner on Apr 10, 2022. It is now read-only.

Commit

Permalink
add change logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitalii Ofat committed Nov 6, 2015
1 parent 90cbd19 commit baf6683
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Ofat/DbConfigAdmin/LogItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class LogItem extends \Eloquent
'updated_at'
];

public function __construct(array $attributes)
public function __construct(array $attributes = [])
{
parent::__construct($attributes);
$this->table = \Config::get('dbConfigAdmin.logs_table', 'settings_logs');
Expand Down
11 changes: 11 additions & 0 deletions src/controllers/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ public function store()
{
foreach($value as $key=>$v)
{
isset($oldValue[$key]) or $oldValue[$key] = '';
isset($oldComment[$key]) or $oldComment[$key] = '';

if($oldValue[$key] != $value[$key] || $oldComment[$key] != $comment[$key])
{
LogItem::create([
Expand All @@ -63,4 +66,12 @@ public function store()

return \Redirect::back();
}

public function logs()
{
$logs = LogItem
::orderBy('created_at', 'desc')
->paginate();
return \View::make('dbConfigAdmin::logs', compact('logs'));
}
}
5 changes: 5 additions & 0 deletions src/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
'as' => 'dbConfigAdmin.store'
]);

Route::get('admin/settings/logs', [
'uses' => 'Ofat\DbConfigAdmin\AdminController@logs',
'as' => 'dbConfigAdmin.logs'
]);

Route::get('admin/settings/{page}', [
'uses' => 'Ofat\DbConfigAdmin\AdminController@manage',
'as' => 'dbConfigAdmin.manage'
Expand Down
37 changes: 37 additions & 0 deletions src/views/logs.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
@extends($layout)

@section('title')
Settings Logs
@stop

@section('main')
<table class="table table-bordered table-condensed table-hover">
<thead>
<tr>
<th>#</th>
<th>Author</th>
<th>Changes</th>
<th>Date</th>
</tr>
</thead>
<tbody>
@foreach($logs as $logItem)
<tr>
<td>{{ $logItem->id }}</td>
<td>{{ $logItem->user_id }}</td>
<td>
{{ $logItem->old_value }} - <em>{{ $logItem->new_value }}</em>
<p class="text-muted">
{{ $logItem->old_comment }} - <em>{{ $logItem->new_comment }}</em>
</p>
</td>
<td>
{{ $logItem->created_at }}
</td>
</tr>
@endforeach
</tbody>
</table>

{{ $logs->links() }}
@stop

0 comments on commit baf6683

Please sign in to comment.