vojtasvoboda / oc-userimportexport-plugin

User import export plugin for OctoberCMS
MIT License
12 stars 6 forks source link

How to add more Database fields #3

Closed bkrajendra closed 8 years ago

bkrajendra commented 8 years ago

How to add more Database fields to import

vojtasvoboda commented 8 years ago

It is not variable for now. If you want to do that quickly, just update https://github.com/vojtasvoboda/oc-userimportexport-plugin/blob/master/models/userimport/columns.yaml file.

bkrajendra commented 8 years ago

@vojtasvoboda I tried this already but somehow its not updating in database. do I need any code to be added in model this is what ive done:

# ===================================
#  Column Definitions
# ===================================

columns:

    username:
        label: rainlab.user::lang.user.username
        searchable: true
        invisible: true

    name:
        label: rainlab.user::lang.user.name
        searchable: true

    surname:
        label: rainlab.user::lang.user.surname
        searchable: true
        invisible: true

    email:
        label: rainlab.user::lang.user.email
        searchable: true

    mobilef:
          label: Fathers Mobile 
          searchable: true

    mobilem:
          label: Mothers Mobile 
          searchable: true

    rollno:
          label: Roll No 
          searchable: true

    # street_addr:
    #     label: Street
    #     searchable: true

    # city:
    #     label: City

    # zip:
    #     label: ZIP

Ive these mobilef, mobilem and rollno columns in db already.

vojtasvoboda commented 8 years ago

Yes, your moves are right. Last step is to extend RainLab User model and add new fillable fields:

// extend RainLab.User model
UserModel::extend(function($model) {
    $model->addFillable(['mobilef', 'mobilem', 'rollno']);
});

See http://octobercms.com/docs/database/model#extending-models

bkrajendra commented 8 years ago

hey @vojtasvoboda , thanks a lot. I forgot that. added it in plugin.php boot method and it worked like charm! Thanks.. nice simple plugin! I'll definitely contribute if i get time to work on it.!

vojtasvoboda commented 8 years ago

I would appreciate more translations if you want to contribute :-) https://github.com/vojtasvoboda/oc-userimportexport-plugin/tree/master/lang