Exemplo n.º 1
0
 protected function syncAdFields(Ad $ad, $request)
 {
     $ad->fields()->detach();
     $fields = $request->get('fields');
     if (!is_array($fields)) {
         return false;
     }
     $authorizedFields = $ad->category->fields()->lists('type', 'fields.id')->toArray();
     foreach ($fields as $fieldId => $value) {
         $this->syncAdField($ad, $authorizedFields, $fieldId, $value);
     }
 }