I am using Laravel's pre-build Auth code. I have another table submissions which looks like this
Schema::create( 'submissions', function( Blueprint $table ) {
$table->increments( 'id' );
$table->enum( 'complete', [ 'yes', 'no' ] );
$table->string( 'formName' );
$table->timestamps();
// Reference to User ID but only when submitted by a registered user...
//$table->integer( 'user_id' )->unsigned();
//$table->foreign( 'user_id' )->references( 'id' )->on( 'users' );
$table->integer( 'status_id' )->unsigned();
$table->foreign( 'status_id' )->references( 'id' )->on( 'status' );
});
When a submission is by a registered user I would like to reference that user id, But anonymous submissions are possible and I need some indicator that the submission is by an anonymous user.
should I?
- creating an actual users records for an anon user
- change my user_id foreign key to allow NULL values to indicate the anon user
or is there a better way?
EDIT: To expand on my use case
My application is basically a collection of forms( aren't they all ) for users to input and update information. Most of the forms will be restricted to Authenticated users. 2-5 forms will be available to both authenticated and non-authenticated users. IF the form submission is done by an Authenticated user I want to indicate to admins who that user is. If the user was not authenticated then I simply want to indicate to the admin that it was an anonymous submission. So Anon users wont require any logic, and this will simply be a flag to indicate the source of hte submission to Admins. That said it sounds like nullable() key on user_id may be the way to go.
Going forward I'm looking at adding tracking so if a submission is made by a user that becomes an authenticated user I can back track and update their submissions to indicate the user.
Thanks
via Nathan