vendredi 30 octobre 2015

Where to put data for select boxes in Laravel?

If I have table in database like this:

users
    id
    username
    status

and status can be:

status 0 - not active 1 - active 2 - banned

where should I put statuses, i have some possibilities:

  1. in repository pattern for users
  2. in User Eloquent class
  3. in helpers
  4. in database (sometimes I would create 50 more tables for this and I don't think this is good idea)
  5. in controller constructor and share it like "View::share('select', $usersStatuses);" i think this is not clean and elegant solution.

?

EDITED:

{!! Form::select('status', user_statuses(), @$user->status, array('class' => 'form-control')) !!}

Look at function "user_statuses()" where and how this should get data ?



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

Aucun commentaire:

Enregistrer un commentaire