Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple Read Mode #4

Merged
merged 2 commits into from
Apr 19, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Prev Previous commit
read mode
  • Loading branch information
ro4 committed Apr 19, 2018
commit 15a57beb970f7eb3376cd9450e1d461b6dc102a6
10 changes: 5 additions & 5 deletions app/Http/Controllers/DocumentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -355,11 +355,11 @@ public function getPageJSON(Request $request, $id, $page_id)
public function readMode($id, $page_id)
{
/** @var Project $project */
$project = Project::with([
'pages' => function (Relation $query) {
$query->select('id', 'pid', 'title', 'description', 'project_id', 'type', 'status');
}
])->findOrFail($id);
$project = Project::query()->findOrFail($id);
$policy = new ProjectPolicy();
if (!$policy->view(\Auth::user(), $project)) {
abort(403, '您没有访问该项目的权限');
}

$page = Document::where('project_id', $id)->where('id', $page_id)->firstOrFail();
$type = $page->type == Document::TYPE_DOC ? 'markdown' : 'swagger';
Expand Down