When I want save my post on posts table, I want to save images on media table too. But in this time, I don't have any image id yet, so how can I sync them ?
I'm using many yo many relationship, and I have tree tables. (media, posts, media_post)
--- (store codes) ---
$image = new Media();
$image->image = str_slug($new_name);
$image->image_path = public_path('images/'.str_slug($new_name));
$image->image_alt_name = $realname;
$image->save();
$post = new Post();
$post->fill(request->all());
$post->save();
So, I don't have any image id yet. How can I get them ?
$post->images()->sync(???,false);
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire