I have three table,employees
,allowances
and emp_allowances
In employees
In allowances
In emp_allowances
Model functions are, Employee
public function empAllowances() {
return $this->belongsToMany('App\Model\EmplAllowance', 'emp_allowances', 'employees_id', 'allowances_id');
}
Allowance
public function employees() {
return $this->belongsToMany('App\Model\Employee');
}
It is working here $emp->empAllowances()->sync([1]);
but when I am following this method,I can not save amount
.
How can I save employee allowance details with amount
?
try
$emp->empAllowances()->sync([1 => ['amount' => 10]])
Search for Adding Pivot Data When Syncing
here
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments