'How can I add a property type array in Laravel livewire
How can I add a property type array in Laravel livewire,
Here is blade file :
@foreach (config('translatable.locales') as $locale => $key)
<div class="col-md-6">
<div class="form-group">
<label> {{ trans('site.' . $key . '.service_title') }} </label>
<input type="text" wire:model="{{ $key }}[service_title]"
class="form-control {{ $errors->has($key . '.service_title') ? 'is-invalid' : '' }} "
name="{{ $key }}[service_title]"
placeholder="{{ trans('site.' . $key . '.service_title') }}">
</div>
</div>
@endforeach
Component :
public $ar = ['service_title' , 'service_description'];
public $en = ['service_title' , 'service_description'];
public function store(ServiceRequest $request)
{
$data = $this->validate($request->rules);
Service::create($data);
session()->flash('success', trans('site.msg_added_successfully'));
}
}
The error when I write on service title input
Thanks
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
