質問

Im trying to add fields to the Users model that is based around Sentry 2 for Laravel 4.

I want to do it properly with migrations.

Is there a way to simply add to the sentry 2 migrations? or should i simply make my own migrations and add the required extra fields?

any guidance with the framework would be awesome!

役に立ちましたか?

解決 2

The purpose of migrations is versioning of the database structure. The answer to any question similar to "where should I put database changes?" is always: "in a new migration", because then you're able to rollback changes.

In this case, I think I would first add Sentry 2 to your project and commit "Added Sentry 2". After, I would create a new migration with your desired changes, then commit: "Added fields x y and z to Users table".

See also the introduction paragraph of the documentation: http://four.laravel.com/docs/migrations

他のヒント

If you want add some fields you need this:

  • run Sentry Migrations: php artisan migrate --package=cartalyst/sentry
  • create a migration to add custom fields to Users table: php artisan migrate:make --table=users
  • example in funcion up():

Schema::table('users', function(Blueprint $table) { $table->string('new_field'); });

  • And then extend the Sentry User Model:

Check this example is extending Sentry Model and full implementation example check this: Laravel 4 Backend and simple web site

The best way to do this is simple navigate to the actual sentry migration file found at

vendor/cartalyst/sentry/src/migrations

copy the needed migrations out and create your own migrations file.

There is no other way. Just me being lazy i guess.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top