laravel 4.2 model polymorphic function
so i am learning laravel and so far i have built an application with signup and sign in and some data which can be stored in the database.
now i have 2 models: the users model which has its own validation set of rules, and another model contact which has its own set of rules.Taking a closer look at how laravel generates its models they both inherit from a base class called Eloquent. what i would like to have is a polymorphic "isValid" function which just validates the user input against the set of rules created in the class the function is called upon.However now when i am creating that for the contact model i find myself repeating my code which is not the best practice for sure.
what i had in mind is add an isValid function in the eloquent model and have it act as a polymorphic function , i am coming from a C++ background which is pretty easy there i have to set the function in the base class as virtual and it will all work accordingly.
or should i use a completely different approach as i am missing something ?
thanks for the help in advance!
链接地址: http://www.djcxy.com/p/83204.html上一篇: Nodejs中的PassportJS从不调用回调函数
下一篇: laravel 4.2模型多态函数