0
votes

I am new in laravel. I create a project in laravel. I have two Route:

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

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('/');
});

I am in page of URL "http://localhost:1234/quickstart/public/".

when I submit in my page, should run Route "Route::post('/task' , function(Request $request)".

after run taht,I go to page "http://localhost:1234/task" instead of page "http://localhost:1234/quickstart/public/task" and get error "Object not found!"

1
Welcome to Stackoverflow. Since you haven't found any answers yet it might help you to edit your question. Explain what you are trying to do and how you tried to solve the problem. For guidance please read how to ask questions and how to create a minimal example5th

1 Answers

0
votes

Welcome To Laravel

In laravel, we don't use this type of route. Don't access public folder directly.

  1. You can Use php artisan serve for local development.
  2. You can also use virtual host.