in database / migrations / create tasks table - paste in up() function
Schema::create('tasks', function (Blueprint $table) { $table->increments('id'); $table->string('title'); $table->text('body'); $table->timestamps(); });
in class Task extends Model
protected $guarded = [];
in app / Http / Controllers / TaskController.php in the public function store(Request $request
Task::create([ 'title' => request('title'), 'body' => request('body') ]); return redirect('/');
in resources / views/ make create.blade.php
<form method="post" action="/tasks"> {{ csrf_field() }} Title <input type="text" class="form-control" id="title" name="title"> Body <textarea id="body" name="body" class="form-control"> <input type="submit" name="Submit" value="submit"> </form>
in routes / web.php
Route::post('/tasks', 'TasksController@store'); Route::get('/create', function() { return view('create'); });