Laravel Save Form Post

by John H
~1 minute

php artisan make:migration tasks

in database / migrations / create tasks table - paste in up()  function

Schema::create('tasks', function (Blueprint $table) {

php artisan make:model Task

in class Task extends Model

protected $guarded = [];

php artisan make:controller TasksController

in app / Http / Controllers / TaskController.php in the public function store(Request $request

'title' => request('title'),
'body' => request('body')

return redirect('/');

Make blade template of form name 'create.blade.php'

in resources / views/ make create.blade.php

<form method="post" action="/tasks">
{{ csrf_field() }}
<input type="text" class="form-control" id="title" name="title">

<textarea id="body" name="body" class="form-control">

<input type="submit" name="Submit" value="submit">

Add Routes for Post and Create in web.php

in routes / web.php

Route::post('/tasks', 'TasksController@store');

Route::get('/create', function() {
return view('create');

Related Articles

Laravel Ajax Button

in blade Has Access $('.grant_access').click(function(){ var options = $(this).data(...

John H John H
2 minutes

Laravel Deployment on Ec2

You gotta have composer installed cd /home/ec2-user/ sudo curl -sS...

John H John H
2 minutes

Lararavel on AWS Linux Storage permissions

Running into issues with Storage logs being denied. Tried this sudo chown -R $USER:apache...

John H John H
~1 minute