dimanche 30 août 2015

Laravel add new array key to eloquent insert

I am trying to add a user_id array key when doing an eloquent insert. I have the following setup:

View

{!! Form::label('supervisors', 'Assign Supervisor(s)') !!}
{!! Form::select('supervisors[][supervisor_id]', $supervisors, null, ['class' => 'chosen-select', 'multiple']) !!}

Currently the request $request->get('supervisors') outputs this:

array:1 [▼
  0 => array:1 [▼
    "supervisor_id" => "1"
  ]
]

However, I would like it to output this:

array:1 [▼
  0 => array:1 [▼
    "supervisor_id" => "1",
    "user_id" => "12"
  ]
]

How can I achieve this dynamically?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1KvpHRD
via IFTTT

Aucun commentaire:

Enregistrer un commentaire