+ add new contributor
+ change sort_order of contributors
This commit is contained in:
parent
9c210a0d96
commit
590c0812fe
5 changed files with 55 additions and 17 deletions
|
@ -342,14 +342,27 @@ class IndexController extends Controller
|
|||
}
|
||||
|
||||
//store contributors
|
||||
// if (isset($data['contributors'])) {
|
||||
// //$data_to_sync = [];
|
||||
// foreach ($request->get('contributors') as $key => $contributor_id) {
|
||||
// $pivot_data = ['role' => 'contributor', 'sort_order' => $key + 1];
|
||||
// //$data_to_sync[$contributor_id] = $pivot_data;
|
||||
// $dataset->persons()->attach($contributor_id, $pivot_data);
|
||||
// }
|
||||
// //$dataset->persons()->sync($data_to_sync);
|
||||
// }
|
||||
if (isset($data['contributors'])) {
|
||||
//$data_to_sync = [];
|
||||
foreach ($request->get('contributors') as $key => $contributor_id) {
|
||||
foreach ($request->get('contributors') as $key => $contributor) {
|
||||
$pivot_data = ['role' => 'contributor', 'sort_order' => $key + 1];
|
||||
//$data_to_sync[$contributor_id] = $pivot_data;
|
||||
$dataset->persons()->attach($contributor_id, $pivot_data);
|
||||
if (isset($contributor['id'])) {
|
||||
//$data_to_sync[$person['id']] = $pivot_data;
|
||||
$dataset->persons()->attach($contributor['id'], $pivot_data);
|
||||
} else {
|
||||
$dataContributor = new Person($contributor);
|
||||
$dataset->persons()->save($dataContributor, $pivot_data);
|
||||
}
|
||||
}
|
||||
//$dataset->persons()->sync($data_to_sync);
|
||||
}
|
||||
|
||||
//store submitters
|
||||
|
|
Loading…
Add table
editor.link_modal.header
Reference in a new issue