app/Http/Controllers/ThreadController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Thread  $thread
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update($channel, Thread $thread)
    {
        $this->authorize('update', $thread);
        $thread->update(request()->validate([
            'title' => ['required', new SpamFree()],
            'body' => ['required', new SpamFree()],
        ]));
        return $thread;
    }
public function update ( $ channel , Thread $ thread ) { $ this -> authorize ( 'update' , $ thread ) ; $ thread -> update ( request ( ) -> validate ( [ 'title' => [ 'required' , new SpamFree ( ) ] , 'body' => [ 'required' , new SpamFree ( ) ] , ] ) ) ; return $ thread ; }
Update the specified resource in storage.
Update the specified resource in storage .
// Refactored: move to LockedThreadsController /* if (request()->has('locked')) {
            // authorization
            if (! auth()->user()->isAdmin()) {
                return response('', 403);
            }

            $thread->lock();
        } */ // This is good, but a little bit confusing. // You need to know tap and HigherOrderTapProxy /* return tap($thread)->update(request()->validate([
            'title' => ['required', new SpamFree()],
            'body' => ['required', new SpamFree()],
        ])); */ // wrap them above will return a boolean of updated or not. // $thread->update(request(['title', 'body']));