Laravel registration method do not give next available id to new user - laravel

When a new user is registered through the registration form of Laravel framework, the id given to this new user is not the next id that exists in table users.
To give you an example, take a look to the next picture:
The id of the new registered user should be 6, and not 22.
What I assume is that for testing purposes I already have deleted some users from table users and that maybe the reason of the gap of ids.
Any ideas how to fix this?

Ids will not get reused, id column is using auto_increment by default
1 - user 1
2 - deleted
3 - deleted
4 - new user // new user will get id 4 not 2
if you manually delete users when doing your tests you should reset auto_increment
example with phpmyadmin
there is a AUTO_INCREMENT field you need to reset to the value you want

Related

Using Laravel's Fortify, how do you modify a column attribute before its sent to the front end?

I am using Vue 3, Laravel Inertia with Fortify. In my users table, I have added a column, location_id.
When updating the user, the location id is passed to the server as a UUID, which attempts to find the Location model based on the UUID and then saves the ID of the Location against the user, so for example:
id | uuid | name | location_id
1 asdf John smith 15
When load the user profile page, location_id is passed down as 15. I can't see where I can modify that user payload that's pre-injected into each page to change this to be the Location's UUID? I have set up the location() relationship on the User model.
Thanks

Laravel - Login Fail after adding mutator on User id

I have classic user id table where the primary key is BigIncrement.
I need to hide the id value from user. So my idea is to use hashIds packages.
What I've done to mask the id is by creating mutator on id column:
public function getIdAttribute($id)
{
return Hashids::connection(User::class)->encode($id);
}
The masking working good, but problem happens when I try to login.
Seems the login session is not created.
My questions are:
Why the login is failed after creating id mutator? I assume that to create session it involve the id value
Any better way to mask the id, besides using mutator?

How to get number of session in laravel project?

I have a basic laravel project which have login, logout and some others basic public pages.
I would like to count all session for the current time(now time). Any session that should be count login user or visit any public pages.
From this project, I would like to know how many session is running?
What I understand from your question is, you want a feature in your application where you can count number of user that are logged in to the application.
If that's the case then as stated above you can hack a way around by adding a bool column in users table or whatever table you are using to store users, and whenever any user logs in, you change that column value to 1 and when the user logs out you change the column value to 0.
This way you can count the users by using that column where the column value is true or 1.
Hope this solves your problem.

InvalidRequest in ApiRequestor.php line 103: No such plan: small; one exists with a name of small, but its ID is 1

In my stripe account, customer generated, test payment is also made. In my app, user table populated with stripe details.
But subscriptions table is not updated in DB, now its telling me:
InvalidRequest in ApiRequestor.php line 103:
No such plan: small; one exists with a name of small, but its ID is 1.
Here code in my controller"
$creditCardToken=$request->input('stripe-token');
Auth::user()->newSubscription('main', $request->input('plan'))->create($creditCardToken);
return "done";
When creating a subscription on the Stripe dashboard you need to input both a unique ID and a Name.
In this case you have set the ID to '1' and the name to 'small' so Stripe is telling you there is no plan with that ID but there is one with a name of small, which is kind of a nice hint.
If you want to refer to the plan you have there you need to either update the ID of the Stripe plan to 'small' or update your form request to reference the plan as ID '1'.
Hope it helps!

How to start with a different Customer ID in Magento?

In Magento Community v1.5.1.0, how would one go about setting the starting (or next) Customer ID? By default, the first Customer ID is 1. I need to start at Customer ID 300000 after clearing out test data before moving a store into production.
Order, Invoice, Shipment, and Credit Memo ID's can be changed by updating the appropriate values in the eav_entity_store, but (contrary to the information here) there is not an increment entry for Customer ID there.
I scanned the database for a "customer"-related table that would achieve the same thing as eav_entity_store but no dice, and my Google-Fu failed as well.
I thought it was not possible in magento, But it will done by MySql query. Run the below query manually and you will get the user id starts from 300001
ALTER TABLE customer_entity AUTO_INCREMENT = 300001;
There is no increment for customer in eav_entity_store but one can be created, perhaps in a module's install script...
$customerType = Mage::getModel('eav/entity_type')->loadByCode('customer');
Mage::getModel('eav/entity_store')
// customer increments are not per store so store_id is 0
->loadByEntityStore($customerType->getId(), 0)
// increments are varchar, not ints
->setIncrementPrefix('3')
->setIncrementLastId('300000')
->save();

Resources