Reputation: 2379
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
?
Upvotes: 2
Views: 115
Reputation: 10300
try
$emp->empAllowances()->sync([1 => ['amount' => 10]])
Search for Adding Pivot Data When Syncing
here
Upvotes: 2