monaabdo88
1 month ago
634
4
Laravel

Array to string conversion laravel 5.8

Posted 1 month ago by monaabdo88

I am trying to update my site settings table fields by using Laravel 5.8 and axios

but in call update message in Vue file I receive this error in my console Array to string conversion

Settings Controller

public function updateSettings(Request $request,Setting $setting){ $siteSettings = $request->siteSettings; foreach($siteSettings as $key => $req){ $siteSettingUpdate = $setting->where('namesetting' , $key)->get()[0]; $siteSettingUpdate->fill(['value' => $req])->save(); } return response()->json($siteSettings); //return response()->json(['Changed Had Saved Successfully'],200); }

settings vue

Update Site Settings

{{site.slug}} {{site.value}} Open Close {{ loading ? 'Saving Please Wait ....' : 'Save Changes' }} export default { data(){ return{ siteSettings:[], loading : false, csrf: document.querySelector('meta[name="csrf-token"]').getAttribute('content') } }, methods:{ getSettings(){ let uri = "/dashboard/getSettings"; axios.get(uri) .then(response =>{ this.siteSettings = response.data; }) }, updateSettings(){ let url ='/dashboard/updateSettings'; this.loading = true; axios.post(url,{siteSettings:this.siteSettings}).then(response =>{ toastr.success(); }).catch(err => { this.loading = false; toastr.error(); }) } }, mounted: function mounted() { this.getSettings(); } }

Please sign in or create an account to participate in this conversation.