lundi 27 mars 2017

500 Internet Server Error after Form submitting

i started the laracast tutorial laravel 5.4 from scratch. Now i'm in session 12 and have my first bug. i GET A 500 Internet Server Error after submitting a empty form. I try a lot, but i can't fix it.

Here are the relevant code:

web.php

Route::get('/', 'PostsController@index');
Route::get('/posts/create', 'PostsController@create');
Route::post('/posts', 'PostsController@store');

PostController.php

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Post;
class PostsController extends Controller
{
    public function index()      
    {
      return view('posts.index');
    }

     public function show()
    {
        return view('posts.show');
    }
    public function create()
    {
        return view('posts.create');
    }
        public function store()
    {
            $this->validate(request, [
                'title' => 'required',
                'body'=> 'required'
            ]);
            Post::create(request(['title', 'body']));
            return redirect('/');          

    }

}

create.blate.php

@extends('layouts.master')


@section ('content')

<h1>Publish a Post</h1>
<hr>
<form method="POST" action="/posts">
    
    <div class="form-group">
    <label for="title">Title</label>
    <input type="text" class="form-control" id="title" name="title">
  </div>
  <div class="form-group">
    <label for="body">Body</label>
    <textarea type="text" class="form-control" id="body" name="body" ></textarea>
  </div>
  <button type="submit" class="btn btn-primary">Publish</button>
</form>

@endsection

Post.php

<?php

namespace App;


class Post extends Model
{

}

Model.php

<?php

namespace App;

use Illuminate\Database\Eloquent\Model as Eloquent;

class Model extends Eloquent
{
    protected $guarded = [];
}

hope someone can help me, laravel don't give me an error.

Best regards



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2nEfugN
via IFTTT

Aucun commentaire:

Enregistrer un commentaire