Okay, so a bit new to Laravel 4, and I am stuck on a problem.
I am using resource controllers on my routes, but I also have some other functions in my controller. As I said, I am new to Laravel, so I am not even sure that is proper practice.
So, my issue is, is that when I call the edit($id) function as a GET method, and then have the update($id) method as POST, it works fine.
Routes.php
Route::get('tasks/edit/{id}', 'TasksController@edit');
Route::post('tasks/edit', 'TasksController@update');
There routes that aren't working are:
Route::get('tasks/complete/{id}', 'TasksController@complete');
Route::post('tasks/complete', array('as' => 'tasks.completed', 'uses' =>'TasksController@completed')); //I've tried this route a few different ways
In my view, I'm calling the method with the Form::open() call like so:
{{ Form::open(array('route' => array('tasks.completed', $task->id))) }}
And in my TasksController.php my methods are:
/**
* Complete the task
*
* @param int $id
* @return Response
*/
public function complete($id) //GET
{
//Find the task by id and allow to complete
return View::make('tasks.complete')->with('task', Task::find($id));
}
/**
* Update the completion
*
* @param int $id
* @return Response
*/
public function completed($id) //POST
{
$tasks = Task::find($id);
$tasks->complete = Task::completion(); //scope query from Model
$tasks->save();
//Redirect to main tasks list
return Redirect::to('/');
}
No matter what I do, I get the continued error of: Missing Argument 1 for TasksController::completed().
I don't understand why the edit resource will work with no issues, yet the custom functions won't. I am almost positive I am overlooking something, but I just can't seem to figure out what.
Thanks for your help in advance!