You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes you have to define a different table name and even a different database connection or PostgreSQL schemas for your models. Mostly when you start to use laravel with a previously created database where you can't change much.
Your models start to look like
class User extends Authenticatable
{
protected$connection = 'security';
protected$table = 't_user';
}
And your migrations look:
Schema::connection('security')->table('t_user', function (Blueprint$table) {});
It would be nice to have a shorter way of doing this.
Schema::model(User::class, callable) as alias for Schema::table('users', callable)
and Schema::createFor(User::class, callable) as alias for Schema::create('users', callable)
Under the hood, It should get the connection and the table name and set for a migration schema.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Sometimes you have to define a different table name and even a different database connection or PostgreSQL schemas for your models. Mostly when you start to use laravel with a previously created database where you can't change much.
Your models start to look like
And your migrations look:
It would be nice to have a shorter way of doing this.
Schema::model(User::class, callable)
as alias forSchema::table('users', callable)
and
Schema::createFor(User::class, callable)
as alias forSchema::create('users', callable)
Under the hood, It should get the connection and the table name and set for a migration schema.
I will be happy if you find a better solution!
Beta Was this translation helpful? Give feedback.
All reactions