M
M
Maxim2020-05-29 12:07:08
Laravel
Maxim, 2020-05-29 12:07:08

Update not working in Laravel resource?

Created a controller

php artisan make:controller LanguageController --resource --model=Model/Language


but when update method does not see $language

public function update(Request $request, Language $language)


and so it works , I

public function update(Request $request, $id)

send data like this

updatel(){
                const that = this;
                let formData = new FormData();
                formData.append('id', this.edit.id);
                formData.append('name', this.edit.name);
                formData.append('image', this.edit.image);
                formData.append('code', this.edit.code);
                formData.append('locale', this.edit.locale);
                formData.append('sort_order', this.edit.sort_order);
                formData.append('published', this.edit.published);
                formData.append('_method', 'PUT');
                axios.post(this.url.update+this.edit.id, formData)
                    .then((response) => {

                    })
                    .catch(error => {
                        toast.fire({
                            icon: 'error',
                            title: error.response.data.errors
                        });
                    });
            },

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2020-05-29
@Aslero

that's how it should be))

public function update(Request $request, Language $localization)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question