So once again I'm having issues with some Many to Many functions. I have 2 models in a Many to Many relationship, Plays and Conferences.
I'm simply trying to allow a user to link a play to another conference by replacing the related conference id (in pivot table) with the id value they choose in the select box. With Eloquent.
public function update(PlaysEditRequest $request, $id)
{
// get play matching uri id
$play = Play::findOrFail($id);
// get form data
$form_data = $request->all();
// if photo uploaded, create file name, move to images/plays dir, create record, assign record id to form data id
if($file = $request->file('photo_id')){
$file_name = time() . '-' . $file->getClientOriginalName();
$file->move('images/plays', $file_name);
$photo = Photo::create(['path'=> $file_name]);
$form_data['photo_id'] = $photo->id;
}
// get selected conference
$conference = Conference::findOrFail($form_data['conference_id'])->pluck('id')->first();
$conference->save($form_data['conference_id']);
// update record with form data
$play->update($form_data);
// go to conference related plays table & relate the new play to the conference id in the pivot table
//$conference->pluck('id')->first()->save($form_data['conference_id']);
$plays = Play::all();
// create notification
Session::flash('play_updated', 'Success! The play was successfully updated.');
return view('admin.plays.index',compact('plays'));
}
I'm getting different issues from "Call to a member function save() on integer" to some undefineds.. I believe in figuring it yourself as you learn more, but I'm under a deadline and need to move past this. Any ideas? Thanks!