Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function update(Request $request, $id)
- {
- $this->validate($request, [
- 'title' => 'required',
- 'body' => 'required'
- ]);
- $post = Post::find($id); // We could use this here because it's declared on top (Post model)
- $post->title = $request->input('title');
- $post->body = $request->input('body');
- $post->user_id = auth()->user()->id;
- $post->save();
- return redirect('/posts')->with('success', 'Post Updated');
- }
- @extends('layouts.app')
- @section('content')
- <h1>Create Post</h1>
- {!! Form::open(['action' => 'PostsController@store', 'method' => 'POST']) !!}
- <div class="form-group">
- {{Form::label('title', 'Title')}}
- {{Form::text('title', '', ['class' => 'form-control', 'placeholder' => 'Title'])}}
- </div>
- <div class="form-group">
- {{Form::label('body', 'Body')}}
- {{Form::textarea('body', '', ['id' => 'article-ckeditor', 'class' => 'form-control', 'placeholder' => 'Body Text'])}}
- </div>
- {{Form::submit('Submit', ['class' => 'btn btn-primary'])}}
- {!! Form::close() !!}
- @endsection
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement