]> BookStack Code Mirror - bookstack/blobdiff - app/Http/Controllers/ChapterController.php
Page Attachments - Improved UI, Now initially complete
[bookstack] / app / Http / Controllers / ChapterController.php
index a3a939f617bc0218b1563e0220b77dd53bddbab1..57ca58beba9750d9ba3082b57f9202a20f1a2506 100644 (file)
@@ -59,7 +59,7 @@ class ChapterController extends Controller
 
         $input = $request->all();
         $input['priority'] = $this->bookRepo->getNewPriority($book);
-        $chapter = $this->chapterRepo->createFromInput($request->all(), $book);
+        $chapter = $this->chapterRepo->createFromInput($input, $book);
         Activity::add($chapter, 'chapter_create', $book->id);
         return redirect($chapter->getUrl());
     }
@@ -117,7 +117,7 @@ class ChapterController extends Controller
         $this->checkOwnablePermission('chapter-update', $chapter);
         $chapter->fill($request->all());
         $chapter->slug = $this->chapterRepo->findSuitableSlug($chapter->name, $book->id, $chapter->id);
-        $chapter->updated_by = auth()->user()->id;
+        $chapter->updated_by = user()->id;
         $chapter->save();
         Activity::add($chapter, 'chapter_update', $book->id);
         return redirect($chapter->getUrl());
@@ -171,6 +171,14 @@ class ChapterController extends Controller
         ]);
     }
 
+    /**
+     * Perform the move action for a chapter.
+     * @param $bookSlug
+     * @param $chapterSlug
+     * @param Request $request
+     * @return mixed
+     * @throws \BookStack\Exceptions\NotFoundException
+     */
     public function move($bookSlug, $chapterSlug, Request $request) {
         $book = $this->bookRepo->getBySlug($bookSlug);
         $chapter = $this->chapterRepo->getBySlug($chapterSlug, $book->id);
@@ -196,7 +204,7 @@ class ChapterController extends Controller
             return redirect()->back();
         }
 
-        $this->chapterRepo->changeBook($parent->id, $chapter);
+        $this->chapterRepo->changeBook($parent->id, $chapter, true);
         Activity::add($chapter, 'chapter_move', $chapter->book->id);
         session()->flash('success', sprintf('Chapter moved to "%s"', $parent->name));