Im new in laravel, please help me with this thing
I have store method in controller and try to set property in that method
public function store(Request $request) {
$configuration = $this->validate(request(), [
'device_name' => 'required',
'sn' => 'required'
]);
$configuration->timezone = "+4";
configuration::create($configuration);
return back()->with('success', 'configuration has been added');
}
But when I try to submit the request I get this error
Attempt to assign property of non-object
What did i do wrong in above method?
The problem is:
$configuration->timezone = "+4";
line. $configuration
is PHP array and not object. Change it into:
$configuration['timezone'] = '+4';
to make it work.