Illegal offset type when adding extra fields to pivot . problem is with the $user

  laravel, multiple-columns, pivot, store

i have a pivot table that i want to record some data along with user on form submit. but im getting an error illegal offset type. $user has a value. same value if i add manually it works.

my controller

    public function store(User $user)
        $data = request()->validate([

            'title' => 'required',
            'link' => 'required',
            'startDate' => 'required',
            'endDate' => 'required',

        $employer = Auth::User();
            $user =>[
                'title' => Request()->title,
                'link' => Request()->link,
                'startDate' => Request()->startDate,
                'endDate' => Request()->endDate,

        return 'success';

Source: Laravel

Leave a Reply