src/Services/PostsService.php
/**
     * Update a BlogEtcPost with new attributes and/or images.
     *
     * N.B. I dislike sending the whole Request object around, this will get refactored.
     *
     * Does not currently use repo calls - works direct on Eloquent. This will change.
     *
     * @param int $blogPostID
     * @param PostRequest $request
     *
     * @return Post
     * @throws Exception
     */
Update a BlogEtcPost with new attributes and/or images.

Does not currently use repo calls - works direct on Eloquent. This will change.



@return Post
@throws Exception
Update a BlogEtcPost with new attributes and / or images . Does not currently use repo calls - works direct on Eloquent . This will change . @return Post @throws Exception
public function update(int $blogPostID, PostRequest $request): Post
    {
        $post = $this->repository->find($blogPostID);
        $post->fill($request->validated());
        $this->uploadsService->processFeaturedUpload($request, $post);
        $post->save();
        $post->categories()->sync($request->categories());
        event(new BlogPostEdited($post));
        return $post;
    }
public function update ( int $ blogPostID , PostRequest $ request ) : Post { $ post = $ this -> repository -> find ( $ blogPostID ) ; $ post -> fill ( $ request -> validated ( ) ) ; $ this -> uploadsService -> processFeaturedUpload ( $ request , $ post ) ; $ post -> save ( ) ; $ post -> categories ( ) -> sync ( $ request -> categories ( ) ) ; event ( new BlogPostEdited ( $ post ) ) ; return $ post ; }
Update a BlogEtcPost with new attributes and/or images.
Update a BlogEtcPost with new attributes and / or images .
// get the post: // update it: // TODO - split this into a repo call. // save any uploaded image: // TODO - copy logic from create! this is now wrong // save changes: // sync post categories: