]> BookStack Code Mirror - bookstack/blob - app/Http/Controllers/PageController.php
Changes as per code review, and fixes failing test cases.
[bookstack] / app / Http / Controllers / PageController.php
1 <?php namespace BookStack\Http\Controllers;
2
3 use Activity;
4 use BookStack\Exceptions\NotFoundException;
5 use BookStack\Repos\EntityRepo;
6 use BookStack\Repos\UserRepo;
7 use BookStack\Services\ExportService;
8 use Illuminate\Http\Request;
9 use Illuminate\Http\Response;
10 use Views;
11 use GatherContent\Htmldiff\Htmldiff;
12
13 class PageController extends Controller
14 {
15
16     protected $entityRepo;
17     protected $exportService;
18     protected $userRepo;
19
20     /**
21      * PageController constructor.
22      * @param EntityRepo $entityRepo
23      * @param ExportService $exportService
24      * @param UserRepo $userRepo
25      */
26     public function __construct(EntityRepo $entityRepo, ExportService $exportService, UserRepo $userRepo)
27     {
28         $this->entityRepo = $entityRepo;
29         $this->exportService = $exportService;
30         $this->userRepo = $userRepo;
31         parent::__construct();
32     }
33
34     /**
35      * Show the form for creating a new page.
36      * @param string $bookSlug
37      * @param string $chapterSlug
38      * @return Response
39      * @internal param bool $pageSlug
40      * @throws NotFoundException
41      */
42     public function create($bookSlug, $chapterSlug = null)
43     {
44         if ($chapterSlug !== null) {
45             $chapter = $this->entityRepo->getBySlug('chapter', $chapterSlug, $bookSlug);
46             $book = $chapter->book;
47         } else {
48             $chapter = null;
49             $book = $this->entityRepo->getBySlug('book', $bookSlug);
50         }
51
52         $parent = $chapter ? $chapter : $book;
53         $this->checkOwnablePermission('page-create', $parent);
54
55         // Redirect to draft edit screen if signed in
56         if ($this->signedIn) {
57             $draft = $this->entityRepo->getDraftPage($book, $chapter);
58             return redirect($draft->getUrl());
59         }
60
61         // Otherwise show the edit view if they're a guest
62         $this->setPageTitle(trans('entities.pages_new'));
63         return view('pages/guest-create', ['parent' => $parent]);
64     }
65
66     /**
67      * Create a new page as a guest user.
68      * @param Request $request
69      * @param string $bookSlug
70      * @param string|null $chapterSlug
71      * @return mixed
72      * @throws NotFoundException
73      */
74     public function createAsGuest(Request $request, $bookSlug, $chapterSlug = null)
75     {
76         $this->validate($request, [
77             'name' => 'required|string|max:255'
78         ]);
79
80         if ($chapterSlug !== null) {
81             $chapter = $this->entityRepo->getBySlug('chapter', $chapterSlug, $bookSlug);
82             $book = $chapter->book;
83         } else {
84             $chapter = null;
85             $book = $this->entityRepo->getBySlug('book', $bookSlug);
86         }
87
88         $parent = $chapter ? $chapter : $book;
89         $this->checkOwnablePermission('page-create', $parent);
90
91         $page = $this->entityRepo->getDraftPage($book, $chapter);
92         $this->entityRepo->publishPageDraft($page, [
93             'name' => $request->get('name'),
94             'html' => ''
95         ]);
96         return redirect($page->getUrl('/edit'));
97     }
98
99     /**
100      * Show form to continue editing a draft page.
101      * @param string $bookSlug
102      * @param int $pageId
103      * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
104      */
105     public function editDraft($bookSlug, $pageId)
106     {
107         $draft = $this->entityRepo->getById('page', $pageId, true);
108         $this->checkOwnablePermission('page-create', $draft->parent);
109         $this->setPageTitle(trans('entities.pages_edit_draft'));
110
111         $draftsEnabled = $this->signedIn;
112         return view('pages/edit', [
113             'page' => $draft,
114             'book' => $draft->book,
115             'isDraft' => true,
116             'draftsEnabled' => $draftsEnabled
117         ]);
118     }
119
120     /**
121      * Store a new page by changing a draft into a page.
122      * @param  Request $request
123      * @param  string $bookSlug
124      * @param  int $pageId
125      * @return Response
126      */
127     public function store(Request $request, $bookSlug, $pageId)
128     {
129         $this->validate($request, [
130             'name' => 'required|string|max:255'
131         ]);
132
133         $input = $request->all();
134         $draftPage = $this->entityRepo->getById('page', $pageId, true);
135         $book = $draftPage->book;
136
137         $parent = $draftPage->parent;
138         $this->checkOwnablePermission('page-create', $parent);
139
140         if ($parent->isA('chapter')) {
141             $input['priority'] = $this->entityRepo->getNewChapterPriority($parent);
142         } else {
143             $input['priority'] = $this->entityRepo->getNewBookPriority($parent);
144         }
145
146         $page = $this->entityRepo->publishPageDraft($draftPage, $input);
147
148         Activity::add($page, 'page_create', $book->id);
149         return redirect($page->getUrl());
150     }
151
152     /**
153      * Display the specified page.
154      * If the page is not found via the slug the revisions are searched for a match.
155      * @param string $bookSlug
156      * @param string $pageSlug
157      * @return Response
158      * @throws NotFoundException
159      */
160     public function show($bookSlug, $pageSlug)
161     {
162         try {
163             $page = $this->entityRepo->getBySlug('page', $pageSlug, $bookSlug);
164         } catch (NotFoundException $e) {
165             $page = $this->entityRepo->getPageByOldSlug($pageSlug, $bookSlug);
166             if ($page === null) {
167                 throw $e;
168             }
169             return redirect($page->getUrl());
170         }
171
172         $this->checkOwnablePermission('page-view', $page);
173
174         $page->html = $this->entityRepo->renderPage($page);
175         $sidebarTree = $this->entityRepo->getBookChildren($page->book);
176         $pageNav = $this->entityRepo->getPageNav($page->html);
177
178         // check if the comment's are enabled
179         $commentsEnabled = !setting('app-disable-comments');
180         if ($commentsEnabled) {
181             $page->load(['comments.createdBy']);
182         }
183
184         Views::add($page);
185         $this->setPageTitle($page->getShortName());
186         return view('pages/show', [
187             'page' => $page,'book' => $page->book,
188             'current' => $page,
189             'sidebarTree' => $sidebarTree,
190             'commentsEnabled' => $commentsEnabled,
191             'pageNav' => $pageNav
192         ]);
193     }
194
195     /**
196      * Get page from an ajax request.
197      * @param int $pageId
198      * @return \Illuminate\Http\JsonResponse
199      */
200     public function getPageAjax($pageId)
201     {
202         $page = $this->entityRepo->getById('page', $pageId);
203         return response()->json($page);
204     }
205
206     /**
207      * Show the form for editing the specified page.
208      * @param string $bookSlug
209      * @param string $pageSlug
210      * @return Response
211      */
212     public function edit($bookSlug, $pageSlug)
213     {
214         $page = $this->entityRepo->getBySlug('page', $pageSlug, $bookSlug);
215         $this->checkOwnablePermission('page-update', $page);
216         $this->setPageTitle(trans('entities.pages_editing_named', ['pageName'=>$page->getShortName()]));
217         $page->isDraft = false;
218
219         // Check for active editing
220         $warnings = [];
221         if ($this->entityRepo->isPageEditingActive($page, 60)) {
222             $warnings[] = $this->entityRepo->getPageEditingActiveMessage($page, 60);
223         }
224
225         // Check for a current draft version for this user
226         if ($this->entityRepo->hasUserGotPageDraft($page, $this->currentUser->id)) {
227             $draft = $this->entityRepo->getUserPageDraft($page, $this->currentUser->id);
228             $page->name = $draft->name;
229             $page->html = $draft->html;
230             $page->markdown = $draft->markdown;
231             $page->isDraft = true;
232             $warnings [] = $this->entityRepo->getUserPageDraftMessage($draft);
233         }
234
235         if (count($warnings) > 0) {
236             session()->flash('warning', implode("\n", $warnings));
237         }
238
239         $draftsEnabled = $this->signedIn;
240         return view('pages/edit', [
241             'page' => $page,
242             'book' => $page->book,
243             'current' => $page,
244             'draftsEnabled' => $draftsEnabled
245         ]);
246     }
247
248     /**
249      * Update the specified page in storage.
250      * @param  Request $request
251      * @param  string $bookSlug
252      * @param  string $pageSlug
253      * @return Response
254      */
255     public function update(Request $request, $bookSlug, $pageSlug)
256     {
257         $this->validate($request, [
258             'name' => 'required|string|max:255'
259         ]);
260         $page = $this->entityRepo->getBySlug('page', $pageSlug, $bookSlug);
261         $this->checkOwnablePermission('page-update', $page);
262         $this->entityRepo->updatePage($page, $page->book->id, $request->all());
263         Activity::add($page, 'page_update', $page->book->id);
264         return redirect($page->getUrl());
265     }
266
267     /**
268      * Save a draft update as a revision.
269      * @param Request $request
270      * @param int $pageId
271      * @return \Illuminate\Http\JsonResponse
272      */
273     public function saveDraft(Request $request, $pageId)
274     {
275         $page = $this->entityRepo->getById('page', $pageId, true);
276         $this->checkOwnablePermission('page-update', $page);
277
278         if (!$this->signedIn) {
279             return response()->json([
280                 'status' => 'error',
281                 'message' => trans('errors.guests_cannot_save_drafts'),
282             ], 500);
283         }
284
285         $draft = $this->entityRepo->updatePageDraft($page, $request->only(['name', 'html', 'markdown']));
286
287         $updateTime = $draft->updated_at->timestamp;
288         return response()->json([
289             'status'    => 'success',
290             'message'   => trans('entities.pages_edit_draft_save_at'),
291             'timestamp' => $updateTime
292         ]);
293     }
294
295     /**
296      * Redirect from a special link url which
297      * uses the page id rather than the name.
298      * @param int $pageId
299      * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
300      */
301     public function redirectFromLink($pageId)
302     {
303         $page = $this->entityRepo->getById('page', $pageId);
304         return redirect($page->getUrl());
305     }
306
307     /**
308      * Show the deletion page for the specified page.
309      * @param string $bookSlug
310      * @param string $pageSlug
311      * @return \Illuminate\View\View
312      */
313     public function showDelete($bookSlug, $pageSlug)
314     {
315         $page = $this->entityRepo->getBySlug('page', $pageSlug, $bookSlug);
316         $this->checkOwnablePermission('page-delete', $page);
317         $this->setPageTitle(trans('entities.pages_delete_named', ['pageName'=>$page->getShortName()]));
318         return view('pages/delete', ['book' => $page->book, 'page' => $page, 'current' => $page]);
319     }
320
321
322     /**
323      * Show the deletion page for the specified page.
324      * @param string $bookSlug
325      * @param int $pageId
326      * @return \Illuminate\View\View
327      * @throws NotFoundException
328      */
329     public function showDeleteDraft($bookSlug, $pageId)
330     {
331         $page = $this->entityRepo->getById('page', $pageId, true);
332         $this->checkOwnablePermission('page-update', $page);
333         $this->setPageTitle(trans('entities.pages_delete_draft_named', ['pageName'=>$page->getShortName()]));
334         return view('pages/delete', ['book' => $page->book, 'page' => $page, 'current' => $page]);
335     }
336
337     /**
338      * Remove the specified page from storage.
339      * @param string $bookSlug
340      * @param string $pageSlug
341      * @return Response
342      * @internal param int $id
343      */
344     public function destroy($bookSlug, $pageSlug)
345     {
346         $page = $this->entityRepo->getBySlug('page', $pageSlug, $bookSlug);
347         $book = $page->book;
348         $this->checkOwnablePermission('page-delete', $page);
349         $this->entityRepo->destroyPage($page);
350
351         Activity::addMessage('page_delete', $book->id, $page->name);
352         session()->flash('success', trans('entities.pages_delete_success'));
353         return redirect($book->getUrl());
354     }
355
356     /**
357      * Remove the specified draft page from storage.
358      * @param string $bookSlug
359      * @param int $pageId
360      * @return Response
361      * @throws NotFoundException
362      */
363     public function destroyDraft($bookSlug, $pageId)
364     {
365         $page = $this->entityRepo->getById('page', $pageId, true);
366         $book = $page->book;
367         $this->checkOwnablePermission('page-update', $page);
368         session()->flash('success', trans('entities.pages_delete_draft_success'));
369         $this->entityRepo->destroyPage($page);
370         return redirect($book->getUrl());
371     }
372
373     /**
374      * Shows the last revisions for this page.
375      * @param string $bookSlug
376      * @param string $pageSlug
377      * @return \Illuminate\View\View
378      */
379     public function showRevisions($bookSlug, $pageSlug)
380     {
381         $page = $this->entityRepo->getBySlug('page', $pageSlug, $bookSlug);
382         $this->setPageTitle(trans('entities.pages_revisions_named', ['pageName'=>$page->getShortName()]));
383         return view('pages/revisions', ['page' => $page, 'book' => $page->book, 'current' => $page]);
384     }
385
386     /**
387      * Shows a preview of a single revision
388      * @param string $bookSlug
389      * @param string $pageSlug
390      * @param int $revisionId
391      * @return \Illuminate\View\View
392      */
393     public function showRevision($bookSlug, $pageSlug, $revisionId)
394     {
395         $page = $this->entityRepo->getBySlug('page', $pageSlug, $bookSlug);
396         $revision = $page->revisions()->where('id', '=', $revisionId)->first();
397         if ($revision === null) {
398             abort(404);
399         }
400
401         $page->fill($revision->toArray());
402         $this->setPageTitle(trans('entities.pages_revision_named', ['pageName' => $page->getShortName()]));
403
404         return view('pages/revision', [
405             'page' => $page,
406             'book' => $page->book,
407             'revision' => $revision
408         ]);
409     }
410
411     /**
412      * Shows the changes of a single revision
413      * @param string $bookSlug
414      * @param string $pageSlug
415      * @param int $revisionId
416      * @return \Illuminate\View\View
417      */
418     public function showRevisionChanges($bookSlug, $pageSlug, $revisionId)
419     {
420         $page = $this->entityRepo->getBySlug('page', $pageSlug, $bookSlug);
421         $revision = $page->revisions()->where('id', '=', $revisionId)->first();
422         if ($revision === null) {
423             abort(404);
424         }
425
426         $prev = $revision->getPrevious();
427         $prevContent = ($prev === null) ? '' : $prev->html;
428         $diff = (new Htmldiff)->diff($prevContent, $revision->html);
429
430         $page->fill($revision->toArray());
431         $this->setPageTitle(trans('entities.pages_revision_named', ['pageName'=>$page->getShortName()]));
432
433         return view('pages/revision', [
434             'page' => $page,
435             'book' => $page->book,
436             'diff' => $diff,
437             'revision' => $revision
438         ]);
439     }
440
441     /**
442      * Restores a page using the content of the specified revision.
443      * @param string $bookSlug
444      * @param string $pageSlug
445      * @param int $revisionId
446      * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
447      */
448     public function restoreRevision($bookSlug, $pageSlug, $revisionId)
449     {
450         $page = $this->entityRepo->getBySlug('page', $pageSlug, $bookSlug);
451         $this->checkOwnablePermission('page-update', $page);
452         $page = $this->entityRepo->restorePageRevision($page, $page->book, $revisionId);
453         Activity::add($page, 'page_restore', $page->book->id);
454         return redirect($page->getUrl());
455     }
456
457
458     /**
459      * Deletes a revision using the id of the specified revision.
460      * @param string $bookSlug
461      * @param string $pageSlug
462      * @param int $revId
463      * @throws NotFoundException
464      * @throws BadRequestException
465      * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
466      */
467     public function destroyRevision($bookSlug, $pageSlug, $revId)
468     {
469         $page = $this->entityRepo->getBySlug('page', $pageSlug, $bookSlug);
470         $this->checkOwnablePermission('page-delete', $page);
471
472         $revision = $page->revisions()->where('id', '=', $revId)->first();
473         if ($revision === null) {
474             throw new NotFoundException("Revision #{$revId} not found");
475         }
476
477         // Get the current revision for the page
478         $currentRevision = $page->getCurrentRevision();
479
480         // Check if its the latest revision, cannot delete latest revision.
481         if (intval($currentRevision->id) === intval($revId)) {
482             session()->flash('error', trans('entities.revision_cannot_delete_latest'));
483             return response()->view('pages/revisions', ['page' => $page, 'book' => $page->book, 'current' => $page], 400);
484         }
485
486         $revision->delete();
487         session()->flash('success', trans('entities.revision_delete_success'));
488         return view('pages/revisions', ['page' => $page, 'book' => $page->book, 'current' => $page]);
489     }
490
491     /**
492      * Exports a page to a PDF.
493      * https://github.com/barryvdh/laravel-dompdf
494      * @param string $bookSlug
495      * @param string $pageSlug
496      * @return \Illuminate\Http\Response
497      */
498     public function exportPdf($bookSlug, $pageSlug)
499     {
500         $page = $this->entityRepo->getBySlug('page', $pageSlug, $bookSlug);
501         $page->html = $this->entityRepo->renderPage($page);
502         $pdfContent = $this->exportService->pageToPdf($page);
503         return response()->make($pdfContent, 200, [
504             'Content-Type'        => 'application/octet-stream',
505             'Content-Disposition' => 'attachment; filename="' . $pageSlug . '.pdf'
506         ]);
507     }
508
509     /**
510      * Export a page to a self-contained HTML file.
511      * @param string $bookSlug
512      * @param string $pageSlug
513      * @return \Illuminate\Http\Response
514      */
515     public function exportHtml($bookSlug, $pageSlug)
516     {
517         $page = $this->entityRepo->getBySlug('page', $pageSlug, $bookSlug);
518         $page->html = $this->entityRepo->renderPage($page);
519         $containedHtml = $this->exportService->pageToContainedHtml($page);
520         return response()->make($containedHtml, 200, [
521             'Content-Type'        => 'application/octet-stream',
522             'Content-Disposition' => 'attachment; filename="' . $pageSlug . '.html'
523         ]);
524     }
525
526     /**
527      * Export a page to a simple plaintext .txt file.
528      * @param string $bookSlug
529      * @param string $pageSlug
530      * @return \Illuminate\Http\Response
531      */
532     public function exportPlainText($bookSlug, $pageSlug)
533     {
534         $page = $this->entityRepo->getBySlug('page', $pageSlug, $bookSlug);
535         $containedHtml = $this->exportService->pageToPlainText($page);
536         return response()->make($containedHtml, 200, [
537             'Content-Type'        => 'application/octet-stream',
538             'Content-Disposition' => 'attachment; filename="' . $pageSlug . '.txt'
539         ]);
540     }
541
542     /**
543      * Show a listing of recently created pages
544      * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
545      */
546     public function showRecentlyCreated()
547     {
548         $pages = $this->entityRepo->getRecentlyCreatedPaginated('page', 20)->setPath(baseUrl('/pages/recently-created'));
549         return view('pages/detailed-listing', [
550             'title' => trans('entities.recently_created_pages'),
551             'pages' => $pages
552         ]);
553     }
554
555     /**
556      * Show a listing of recently created pages
557      * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
558      */
559     public function showRecentlyUpdated()
560     {
561         $pages = $this->entityRepo->getRecentlyUpdatedPaginated('page', 20)->setPath(baseUrl('/pages/recently-updated'));
562         return view('pages/detailed-listing', [
563             'title' => trans('entities.recently_updated_pages'),
564             'pages' => $pages
565         ]);
566     }
567
568     /**
569      * Show the Restrictions view.
570      * @param string $bookSlug
571      * @param string $pageSlug
572      * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
573      */
574     public function showRestrict($bookSlug, $pageSlug)
575     {
576         $page = $this->entityRepo->getBySlug('page', $pageSlug, $bookSlug);
577         $this->checkOwnablePermission('restrictions-manage', $page);
578         $roles = $this->userRepo->getRestrictableRoles();
579         return view('pages/restrictions', [
580             'page'  => $page,
581             'roles' => $roles
582         ]);
583     }
584
585     /**
586      * Show the view to choose a new parent to move a page into.
587      * @param string $bookSlug
588      * @param string $pageSlug
589      * @return mixed
590      * @throws NotFoundException
591      */
592     public function showMove($bookSlug, $pageSlug)
593     {
594         $page = $this->entityRepo->getBySlug('page', $pageSlug, $bookSlug);
595         $this->checkOwnablePermission('page-update', $page);
596         return view('pages/move', [
597             'book' => $page->book,
598             'page' => $page
599         ]);
600     }
601
602     /**
603      * Does the action of moving the location of a page
604      * @param string $bookSlug
605      * @param string $pageSlug
606      * @param Request $request
607      * @return mixed
608      * @throws NotFoundException
609      */
610     public function move($bookSlug, $pageSlug, Request $request)
611     {
612         $page = $this->entityRepo->getBySlug('page', $pageSlug, $bookSlug);
613         $this->checkOwnablePermission('page-update', $page);
614
615         $entitySelection = $request->get('entity_selection', null);
616         if ($entitySelection === null || $entitySelection === '') {
617             return redirect($page->getUrl());
618         }
619
620         $stringExploded = explode(':', $entitySelection);
621         $entityType = $stringExploded[0];
622         $entityId = intval($stringExploded[1]);
623
624
625         try {
626             $parent = $this->entityRepo->getById($entityType, $entityId);
627         } catch (\Exception $e) {
628             session()->flash(trans('entities.selected_book_chapter_not_found'));
629             return redirect()->back();
630         }
631
632         $this->checkOwnablePermission('page-create', $parent);
633
634         $this->entityRepo->changePageParent($page, $parent);
635         Activity::add($page, 'page_move', $page->book->id);
636         session()->flash('success', trans('entities.pages_move_success', ['parentName' => $parent->name]));
637
638         return redirect($page->getUrl());
639     }
640
641     /**
642      * Show the view to copy a page.
643      * @param string $bookSlug
644      * @param string $pageSlug
645      * @return mixed
646      * @throws NotFoundException
647      */
648     public function showCopy($bookSlug, $pageSlug)
649     {
650         $page = $this->entityRepo->getBySlug('page', $pageSlug, $bookSlug);
651         $this->checkOwnablePermission('page-update', $page);
652         session()->flashInput(['name' => $page->name]);
653         return view('pages/copy', [
654             'book' => $page->book,
655             'page' => $page
656         ]);
657     }
658
659     /**
660      * Create a copy of a page within the requested target destination.
661      * @param string $bookSlug
662      * @param string $pageSlug
663      * @param Request $request
664      * @return mixed
665      * @throws NotFoundException
666      */
667     public function copy($bookSlug, $pageSlug, Request $request)
668     {
669         $page = $this->entityRepo->getBySlug('page', $pageSlug, $bookSlug);
670         $this->checkOwnablePermission('page-update', $page);
671
672         $entitySelection = $request->get('entity_selection', null);
673         if ($entitySelection === null || $entitySelection === '') {
674             $parent = $page->chapter ? $page->chapter : $page->book;
675         } else {
676             $stringExploded = explode(':', $entitySelection);
677             $entityType = $stringExploded[0];
678             $entityId = intval($stringExploded[1]);
679
680             try {
681                 $parent = $this->entityRepo->getById($entityType, $entityId);
682             } catch (\Exception $e) {
683                 session()->flash(trans('entities.selected_book_chapter_not_found'));
684                 return redirect()->back();
685             }
686         }
687
688         $this->checkOwnablePermission('page-create', $parent);
689
690         $pageCopy = $this->entityRepo->copyPage($page, $parent, $request->get('name', ''));
691
692         Activity::add($pageCopy, 'page_create', $pageCopy->book->id);
693         session()->flash('success', trans('entities.pages_copy_success'));
694
695         return redirect($pageCopy->getUrl());
696     }
697
698     /**
699      * Set the permissions for this page.
700      * @param string $bookSlug
701      * @param string $pageSlug
702      * @param Request $request
703      * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
704      * @throws NotFoundException
705      */
706     public function restrict($bookSlug, $pageSlug, Request $request)
707     {
708         $page = $this->entityRepo->getBySlug('page', $pageSlug, $bookSlug);
709         $this->checkOwnablePermission('restrictions-manage', $page);
710         $this->entityRepo->updateEntityPermissionsFromRequest($request, $page);
711         session()->flash('success', trans('entities.pages_permissions_success'));
712         return redirect($page->getUrl());
713     }
714 }