app/Http/Livewire/CrudPost.php
/**
     * The create or update form is submitted.
     *
     * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
     */
The create or update form is submitted.
The create or update form is submitted .
public function submit()
    {
        $validatedAttributes = $this->validate([
            'title' => 'required|min:5',
            'description' => 'required',
            'public' => 'required|boolean',
            'markdown' => 'required',
        ]);
        $post = $this->postId ? Post::findOrFail($this->postId) : new Post();
        if ($this->isUpdating && Auth::id() !== $post->user_id) {
            throw new AuthorizationException();
        }
        $post->fill($validatedAttributes + [
                'user_id' => Auth::id(),
            ]);
        $post->save();
        return redirect()->route('posts.show', [
            'post' => $post,
        ]);
    }
public function submit ( ) { $ validatedAttributes = $ this -> validate ( [ 'title' => 'required|min:5' , 'description' => 'required' , 'public' => 'required|boolean' , 'markdown' => 'required' , ] ) ; $ post = $ this -> postId ? Post :: findOrFail ( $ this -> postId ) : new Post ( ) ; if ( $ this -> isUpdating && Auth :: id ( ) !== $ post -> user_id ) { throw new AuthorizationException ( ) ; } $ post -> fill ( $ validatedAttributes + [ 'user_id' => Auth :: id ( ) , ] ) ; $ post -> save ( ) ; return redirect ( ) -> route ( 'posts.show' , [ 'post' => $ post , ] ) ; }
The create or update form is submitted.
The create or update form is submitted .