I need to save following session value to same table with new column as project_name.
session(['project_name' => $this->getProjectName($id),
'user_email' => $this->getEmail($collaborator_username)
]);
My existing Controller is
public function addCollaborator(Request $request, $id, Collaboration $collaboration)
{
$this->validate($request, [
'collaborator' => 'required|min:5',
]);
$collaborator_username = substr(trim($request->input('collaborator')),1);
$collaboration->project_id = $id;
if( is_null($this->getId($collaborator_username)))
{
return redirect()->back()->with('warning', 'This user does not exist');
}
$collaborationStatus = $this->isCollaborator($id, $this->getId($collaborator_username));
if(! is_null($collaborationStatus))
{
return redirect()->back()->with('warning', 'This user is already a collaborator on this project');
}
$collaboration->collaborator_id = $this->getId($collaborator_username);
session(['project_name' => $this->getProjectName($id),
'user_email' => $this->getEmail($collaborator_username)
]);
$collaboration->save();
return redirect()->back()->with('info', "{$collaborator_username} has been added to your project successfully");
}