mardi 10 avril 2018

laravel model and controller functions

so i have been studying Laravel for a while now and i came across a question in my mind , i get the difference between a static and non static function but i don't see why in most of the tutorials i have been going through the model functions are always a public static function while controller functions are only public functions .

so assuming we have a table "posts" and a model "post" for it, and i am trying to get posts that belong to a certain user_id which is passed as an argument , i don't see the difference between a static or non static function at that point because both will return the same value for any instance in the class hence static and at the same time creating it non static won't ruin the execution in any way. If anyone can provide an example that would make the difference clear to my mind i would be really grateful for it.

I feel the question is stupid and the answer is pretty obvious but i don't get it



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire