public function syncAgentCategories($id, Request $request)
    {
        $form_cats = ($request->input('agent_cats') == null) ? [] : $request->input('agent_cats');
        $agent = Agent::find($id);
        $agent->categories()->sync($form_cats);
    }
public function syncAgentCategories($id, Request $request)
    {
        $form_cats = ($request->input('agent_cats') == null) ? [] : $request->input('agent_cats');
        $agent = Agent::find($id);
        $agent->categories()->sync($form_cats);
    }
public function syncAgentCategories ( $ id , Request $ request ) { $ form_cats = ( $ request -> input ( 'agent_cats' ) == null ) ? [ ] : $ request -> input ( 'agent_cats' ) ; $ agent = Agent :: find ( $ id ) ; $ agent -> categories ( ) -> sync ( $ form_cats ) ; }
Sync Agent categories with the selected categories got from update form.

@param $id
@param Request $request
Sync Agent categories with the selected categories got from update form .