mardi 4 mai 2021

what is the difference between $model properity and newFactroy method in laravel factroy

i have a question regarding why do we need to set protected $model = User::class when defining a Factory and in the model itself we need sometimes (if we did not use a convention for Factory name ) to override newFactory method to tell the model about the Factory ? why we need both of them ? why not to use $model properity only ? or newFactory() only ? why both of them ??

      class UserFactory extends Factory{
protected $model = User::class;
}

and inside the model

   public static function newFactory(){
        return UserFactory::new();
 }


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3vEhLrL
via IFTTT

Aucun commentaire:

Enregistrer un commentaire