app/Http/Controllers/OrganizationController.php
/**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(Request $request)
    {
        $user_id = $request->user_id;
        unset($request['user_id']);
        $organization = Organization::create($request->all());
        if($user_id)$organization->users()->attach($user_id);
        return $organization;
    }
public function store ( Request $ request ) { $ user_id = $ request -> user_id ; unset ( $ request [ 'user_id' ] ) ; $ organization = Organization :: create ( $ request -> all ( ) ) ; if ( $ user_id ) $ organization -> users ( ) -> attach ( $ user_id ) ; return $ organization ; }
Store a newly created resource in storage.
Store a newly created resource in storage .