I need to save project_id
in to task
table according to the relevant projects from using Project
model.
Project
Model
public function scopeProject($query, $id)
{
return $query->where('project_id', $id);
}
Now I am going to save to task table using store method in TaskController as following
public function store(Request $request, $id, Task $task)// this is line 45
{
$task = new Task;
$task->task_name = $request->input('name');
$task->body = $request->input('body');
$task->assign = $request->input('status');
$task->priority = $request->input('status');
$task->duedate = date("Y-m-d", strtotime($request->input("date")));// $request->input('date');
$task->project_id = $id;
$task->save();
}
But when I am going to save this data following error is occurred
ErrorException in TasksController.php line 45: Argument 3 passed to App\Http\Controllers\TasksController::store() must be an instance of App\Task, none given
Then how can I grab project_id
from using Project
Model to My TaskController
?