hellow, I am developing web based project management system in Laravel 5.2 and in my application one project has many tasks and one task have many comments. now I need add relevent task id when user enter some comment to the comment table
CommentsController
public function postNewComment(Request $request, $id, Comment $comment)
{
$this->validate($request, [
'comments' => 'required|min:5',
]);
$comment->comments = $request->input('comments');
$comment->project_id = $id;
$comment->user_id = Auth::user()->id;
$comment->save();
return redirect()->back()->with('info', 'Comment posted successfully');
}
site url is when going to enter some comments on each task is
http://localhost:8000/projects/2/tasks/31
and My existing comments table structure is
id comments project_id user_id
1 fgt 1 1
2 hgyt 1 2
3 jfu 2 1
My routes is
Route::post('projects/{projects}/comments', [
'uses' => 'CommentsController@postNewComment',
'as' => 'projects.comments.create',
'middleware' => ['auth']
]);
how can I enter task id to the comment table?
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2zAqKk4
via IFTTT
Aucun commentaire:
Enregistrer un commentaire