How to get the id of the current model in Laravel when saving
I am working in a Laravel 5 application. I try to save a comment for a project and I don't know how to get the $comment->project_id value. Here is my simplified controller public function store( CommentsFormRequest $request ) { $comment = new Note; $comment->message = Input::get('message'); $comment->project_id = $note->project->id; $comment->user_id = Auth::id(); $comment->save(); return Redirect::back(); } and here is my simplified form {!! Form::open(array('route' => 'notes.store')) !!} {!! Form::textarea('message', '', array('placeholder'=>'Message')) !!} {!! Form::submit('Ajouter la note'
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.