Reputation: 3205
I know it's not possible to use a reserved word in PHP as class name, but my Laravel app enables managing of courses and classes, so I have a database table called classes
, a ClassController
and hopefully a Class
model. However, in Laravel, my model has to be named Class
which is not allowed in PHP:
class Class extends Model {}
Using a synonym, the closest being Lecture
, still doesn't seem right.
Is there a Laravel workaround to this?
Upvotes: 5
Views: 7521
Reputation: 1077
Laravel doesn't force you to use specific names for your models or controllers. It's just a convention. You can name your model whatever you want it to be. the only amend you will have to make is to declare protected $table = 'classes'
in your model
Upvotes: 7