-
Notifications
You must be signed in to change notification settings - Fork 1.4k
SubDocuments #84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Posible Solution: Auth::user()->_id, 'name' => Auth::user()->name); ``` $validation = Post::validate( $data ); if ( $validation->passes() ) { $post = Post::create( $data ); return Response::json( array('flash' => 'Publicado!')); } else { return Response::json( array('flash' => $validation->messages()->first()), 500 ); } ``` } ?> |
There a multiple ways to store subdocuments. You can do it the Eloquent way with relations, or do it manually and insert arrays/objects as model attributes. |
With eloquent it's implemented? $user = User::find('a23s988a8sa98s9')->get(); $post->user = $user; $post->user() = $user; i get error mass assignment... |
Check out 'inserting related models' on http://laravel.com/docs/eloquent#relationships. This will not create an actual subdocument, but will store a reference to the related object. |
I don't understand, but now it's working :| Thanks and i'm sorry! |
How attach a embbed document in a model?
For example in post an user.
Post: {
title: 'something',
body: 'somethng',
user: {
_id: '1267a6767hs67',
name: 'Bruno Cascio',
}
}
How to insert post with that model?
The text was updated successfully, but these errors were encountered: