Files
core/app/Http/Controllers/Admin/History.php
T
Michal Kváček 620a5545d8 FEATURE #1373: add history of content
This commit contains only core funcionality of displaying history. Module settings must be implemented in each module.
2016-02-05 16:06:13 +01:00

49 lines
1.1 KiB
PHP

<?php
namespace App\Http\Controllers\Admin;
use App\Models\Content;
use App\Models\ContentHistory;
class History extends Controller
{
/**
* @var ContentHistory
*/
private $history;
public function __construct(ContentHistory $history)
{
parent::__construct();
$this->history = $history;
}
/**
* @param $id
*
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function getOverview($id)
{
// test if given content id is static page and if exists
$content = Content::findOrFail($id);
$history = $this->history->getStructuredHistoryOf($content);
return view('admin/history.overview', [
'history' => $history,
'page' => $content
]);
}
public function getDiff($revision, $id)
{
$change = $this->history->findOrFail($id);
$diff = $this->history->getDiff($change);
return view('admin/history.diff', [
'change' => $change,
'columnName' => 'Page content',
'diff' => $diff
]);
}
}