Level 104
new Model will be an instance in memory until it is saved; while Model::create() persists the record in the database immediately. Many operations relying on foreign keys will not work until the former is saved.
1 like
Hello LaraV.I.P.s
Just wondering if the return types of Model::create() and new Model() are supposed to be the same? Or do they differ?
I ask because I would expect them to be the same, but I'm experiencing different behaviour when using one versus the other (especially in the save() and associate() Eloquent methods).
Best regards, Dev Master
new Model will be an instance in memory until it is saved; while Model::create() persists the record in the database immediately. Many operations relying on foreign keys will not work until the former is saved.
Please or to participate in this conversation.