|  | @@ -5,87 +5,100 @@ namespace App\Http\Controllers;
 | 
	
		
			
				|  |  |  use App\Post;
 | 
	
		
			
				|  |  |  use Illuminate\Http\Request;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -class PostsController extends Controller {
 | 
	
		
			
				|  |  | +class PostsController extends Controller
 | 
	
		
			
				|  |  | +{
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -  /**
 | 
	
		
			
				|  |  | -   * Show the form for creating a new resource.
 | 
	
		
			
				|  |  | -   *
 | 
	
		
			
				|  |  | -   * @return \Illuminate\Http\Response
 | 
	
		
			
				|  |  | -   */
 | 
	
		
			
				|  |  | -  public function create() {
 | 
	
		
			
				|  |  | -    return view('posts.create');
 | 
	
		
			
				|  |  | -  }
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * Show the form for creating a new resource.
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  | +     * @return \Illuminate\Http\Response
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    public function create()
 | 
	
		
			
				|  |  | +    {
 | 
	
		
			
				|  |  | +        return view('posts.create');
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -  /**
 | 
	
		
			
				|  |  | -   * Remove the specified resource from storage.
 | 
	
		
			
				|  |  | -   *
 | 
	
		
			
				|  |  | -   * @param  int $id
 | 
	
		
			
				|  |  | -   *
 | 
	
		
			
				|  |  | -   * @return \Illuminate\Http\Response
 | 
	
		
			
				|  |  | -   */
 | 
	
		
			
				|  |  | -  public function destroy($id) {
 | 
	
		
			
				|  |  | -    //
 | 
	
		
			
				|  |  | -  }
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * Remove the specified resource from storage.
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  | +     * @param  int $id
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  | +     * @return \Illuminate\Http\Response
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    public function destroy($id)
 | 
	
		
			
				|  |  | +    {
 | 
	
		
			
				|  |  | +        //
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -  /**
 | 
	
		
			
				|  |  | -   * Show the form for editing the specified resource.
 | 
	
		
			
				|  |  | -   *
 | 
	
		
			
				|  |  | -   * @param  int $id
 | 
	
		
			
				|  |  | -   *
 | 
	
		
			
				|  |  | -   * @return \Illuminate\Http\Response
 | 
	
		
			
				|  |  | -   */
 | 
	
		
			
				|  |  | -  public function edit($id) {
 | 
	
		
			
				|  |  | -    //
 | 
	
		
			
				|  |  | -  }
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * Show the form for editing the specified resource.
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  | +     * @param  int $id
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  | +     * @return \Illuminate\Http\Response
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    public function edit($id)
 | 
	
		
			
				|  |  | +    {
 | 
	
		
			
				|  |  | +        //
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -  /**
 | 
	
		
			
				|  |  | -   * Display a listing of the resource.
 | 
	
		
			
				|  |  | -   *
 | 
	
		
			
				|  |  | -   * @return \Illuminate\Http\Response
 | 
	
		
			
				|  |  | -   */
 | 
	
		
			
				|  |  | -  public function index() {
 | 
	
		
			
				|  |  | -    $posts = Post::all();
 | 
	
		
			
				|  |  | -    return view('posts.index', compact('posts'));
 | 
	
		
			
				|  |  | -  }
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * Display a listing of the resource.
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  | +     * @return \Illuminate\Http\Response
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    public function index()
 | 
	
		
			
				|  |  | +    {
 | 
	
		
			
				|  |  | +        $posts = Post::all();
 | 
	
		
			
				|  |  | +        return view('posts.index', compact('posts'));
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -  public function show(Post $post) {
 | 
	
		
			
				|  |  | -    return view('posts.show', compact('post'));
 | 
	
		
			
				|  |  | -  }
 | 
	
		
			
				|  |  | +    public function show(Post $post)
 | 
	
		
			
				|  |  | +    {
 | 
	
		
			
				|  |  | +        return view('posts.show', compact('post'));
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -  /**
 | 
	
		
			
				|  |  | -   * Store a newly created resource in storage.
 | 
	
		
			
				|  |  | -   *
 | 
	
		
			
				|  |  | -   * - Create new post using the request data
 | 
	
		
			
				|  |  | -   * - Save it to the database
 | 
	
		
			
				|  |  | -   * - Redirect to the home page
 | 
	
		
			
				|  |  | -   *
 | 
	
		
			
				|  |  | -   * @param  \Illuminate\Http\Request $request
 | 
	
		
			
				|  |  | -   *
 | 
	
		
			
				|  |  | -   * @return \Illuminate\Http\Response
 | 
	
		
			
				|  |  | -   */
 | 
	
		
			
				|  |  | -  public function store(Request $request) {
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * Store a newly created resource in storage.
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  | +     * - Create new post using the request data
 | 
	
		
			
				|  |  | +     * - Save it to the database
 | 
	
		
			
				|  |  | +     * - Redirect to the home page
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  | +     * @param  \Illuminate\Http\Request $request
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  | +     * @return \Illuminate\Http\Response
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    public function store(Request $request)
 | 
	
		
			
				|  |  | +    {
 | 
	
		
			
				|  |  |  //    $post = new Post();
 | 
	
		
			
				|  |  |  //    $post->title = $request->get('title');
 | 
	
		
			
				|  |  |  //    $post->body = $request->get('body');
 | 
	
		
			
				|  |  |  //    $post->save();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    Post::create([
 | 
	
		
			
				|  |  | -      'title' => $request->get('title'),
 | 
	
		
			
				|  |  | -      'body' => $request->get('body'),
 | 
	
		
			
				|  |  | -    ]);
 | 
	
		
			
				|  |  | +        $this->validate($request, [
 | 
	
		
			
				|  |  | +            'title' => 'required|min:10',
 | 
	
		
			
				|  |  | +            'body' => 'required',
 | 
	
		
			
				|  |  | +        ]);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    return redirect('/');
 | 
	
		
			
				|  |  | -  }
 | 
	
		
			
				|  |  | +        Post::create([
 | 
	
		
			
				|  |  | +            'title' => $request->get('title'),
 | 
	
		
			
				|  |  | +            'body' => $request->get('body'),
 | 
	
		
			
				|  |  | +        ]);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -  /**
 | 
	
		
			
				|  |  | -   * Update the specified resource in storage.
 | 
	
		
			
				|  |  | -   *
 | 
	
		
			
				|  |  | -   * @param  \Illuminate\Http\Request $request
 | 
	
		
			
				|  |  | -   * @param  int $id
 | 
	
		
			
				|  |  | -   *
 | 
	
		
			
				|  |  | -   * @return \Illuminate\Http\Response
 | 
	
		
			
				|  |  | -   */
 | 
	
		
			
				|  |  | -  public function update(Request $request, $id) {
 | 
	
		
			
				|  |  | -    //
 | 
	
		
			
				|  |  | -  }
 | 
	
		
			
				|  |  | +        return redirect('/');
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * Update the specified resource in storage.
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  | +     * @param  \Illuminate\Http\Request $request
 | 
	
		
			
				|  |  | +     * @param  int $id
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  | +     * @return \Illuminate\Http\Response
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    public function update(Request $request, $id)
 | 
	
		
			
				|  |  | +    {
 | 
	
		
			
				|  |  | +        //
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  }
 |