1

I have created an addition to the profile settings page in Spark. The vue code:

Vue.component('update-mail-settings', {
props: ['user'],

data() {
    return {
        form: new SparkForm({
            type: ''
        })
    };
},

mounted() {
    this.form.mailsettings = this.user.mailsettings;
},

methods: {
    update() {
        Spark.put('update-mail-settings', this.form)
            .then(response => {
                Bus.$emit('updateUser');
            });
    }
}
});

I've created a route:

Route::put('/update-mail-settings', 'SettingsController@updateMailSettings');

and the Controller to handle the request. I disabled CSRF checking and as can be seen in the code beneath, also the auth middleware:

 class SettingsController extends Controller{

  public function __construct(){
//$this->middleware('auth');
 }

public function updateMailSettings(Request $request)
 {
 $request->user()->forceFill([
  'mailsettings' => $request->mailsettings
  ])->save();

  return Redirect::back()->with('success', 'Successfully updated mailsettings');
}
}

I didn't show the blade with radio buttons but that doesn't seem like the source of the error. Interestingly, when I monitor the requests in my Nginx log files I see a 405 error if I click on the update button on the website but if I use Postman, it yields a 500 code (after which it fails since it cannot assign the mailsettings variable --> "Call to a member function forceFill() on null")

Anyone have any idea?

helloworld
  • 223
  • 1
  • 7
  • 24

0 Answers0