Hello everyone.
I have 2 related models in my Laravel 5.6 app
1st is Card model l and and it has a
public function Control()
{
return $this->hasMany('App\Control','card_id');
}
Control model also have a
public function Card()
{
return $this->belongsTo('App\Card');
}
in my resource controller i am going to edit given relation in such way
//CardController
public function update(Request $request, $id)
{
$cards= Card::find($id)->control;
foreach ($cards as $card=>$val)
{
$val->work=$request->get('work')[$card];
//editing 'work' field, i get values from 'work[]' array -it is a textarea fields from my
//edit.blade
$val->save();
}
}
but if i try to add some new textareas in my edit.blade using jquery append method, so i have for example two existing textsareas and i add another 4 textareas, how to add data from this new and old textareas properly? Thank you for attention