I have a Idea and community model. A Many to many relationship exists between them. Relationships are being formed perfectly. however, i am facing one issue. An idea can be found in may communities and a community can have many ideas. So, based on this there is an intermediate table. i am unable to store community_id
and idea_id
in pivot table.
public function storePost(IdeaRequest $request)
{
if ($request->hasFile('idea_image')) {
$filename = $request->file('idea_image')->getClientOriginalName();
$moveImage = $request->file('idea_image')->move('images/', $filename);
}
$idea = new Idea();
$idea->idea_title = $request->input('idea_title');
$idea->user_id = Auth::id();
$idea->idea_image = $moveImage;
$idea->idea_info = $request->input('idea_info');
$idea->communities()->attach($request->input('selection'));
$idea->idea_location = $request->input('idea_location');
$idea->idea_goal = $request->input('idea_goal');
$idea->idea_description = strip_tags($request->input('idea_description'));
$idea->save();
Session::set('idea_id',$idea->id);
session()->flash('flash_message', 'Your idea has been submitted for Review, Kindly Fill this Work BreakDown of You Work');
return redirect()->route('create_wbs');
}
This line is making issue
$idea->communities()->attach($request->input('selection'));
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire