laravelwebdev's avatar

Select database on login form nova

In laravel Nova login form, i want to add select filed for choosing database (examp: database2023 and database2024). When user login, it will connect to chosen database. How to

  1. Add select filed to login form of laravel nova
  2. when logging in, how to set laravel nova connect to choosen database
0 likes
11 replies
Tray2's avatar

Why do you have/need multiple databases?

One database will most likely suffice for all your needs.

Tray2's avatar

@laravelwebdev No need, the database can handle way more than you think.

The limit of the InnoDB engine is 64TB per table.

If you are worried about performance you can use partitions.

1 like
laravelwebdev's avatar

@Tray2 On the Nova login form page, I want to add a year option (2023,2024,...). When the user logs in, I want to add a session variable containing the selected year

martinbean's avatar

@laravelwebdev How about you just stop creating databases per year? As @tray2 has told you, databases are literally made to hold large amounts of data.

2 likes
JussiMannisto's avatar

@laravelwebdev

want to separate database based on year coz so much record inside it

This is a really weird approach and not how databases are meant to be used. If you have a sensible schema and use indexes where needed, databases can handle a lot of data. That's what they're for.

If you can describe the real issue that you're having, I'm sure people can help you solve it.

How many records are we talking about? Do you have a peformance issue, or are you worried about something else (e.g. backup restoration time)?

2 likes
laravelwebdev's avatar

@Tray2 i wanto to make global scope :

$builder->where('year', session('year'));

but how can i add a year option (2023,2024,...) on the nova login form . When the user logs in, I want to add a session variable containing the selected year

Tray2's avatar

@laravelwebdev The login view should be found in the resources/views directory, check in the vendors directory, if there isn't one, try running php artisan vendor:publish and then you should be able to update the login view.

Please or to participate in this conversation.