I'm currently reading through the documentation and completing this quick-start guide: http://laravel.com/docs/5.1/quickstart#adding-tasks
I'm using Wamp and have installed this Laravel app in "www/laravel/quickstart5/" It works fine to access index through localhost/laravel/quickstart5/public/ When I submit a new task I get redirected to "localhost/task/"
This is my routes.php
<?php
use App\Task;
use Illuminate\Http\Request;
/**
* Display All Tasks
*/
Route::get('/', function () {
$tasks = Task::orderBy('created_at', 'asc')->get();
return view('tasks', [
'tasks' => $tasks
]);
});
/**
* Add A New Task
*/
Route::post('/task', function (Request $request) {
$validator = Validator::make($request->all(), [
'name' => 'required|max:255',
]);
if ($validator->fails()) {
return redirect('/')
->withInput()
->withErrors($validator);
}
$task = new Task;
$task->name = $request->name;
$task->save();
return redirect('/');
// Create The Task...
});
/**
* Delete An Existing Task
*/
Route::delete('/task/{id}', function ($id) {
Task::findOrFail($id)->delete();
return redirect('/');
});
I have a file in /app/ called Task.php
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Task extends Model
{
//
}
I don't understand how this form is suppose to work. "<form action="/task" method="POST" class="form-horizontal">"
The only thing I get is that I guess I should change the .htaccess in the "/public"-folder
Current .htaccess
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]