Answer the question
In order to leave comments, you need to log in
Why is constructor called 3 times after firstOrCreate method in Laravel 5?
There is a constructor in the User class:
public function __construct() {
parent::__construct();
echo "__construct";
}
$users = \App\User::firstOrCreate(['email' => '[email protected]']);
Answer the question
In order to leave comments, you need to log in
Because everything is mixed up in the model: here are facades for calling like through statics, here is a query builder for queries, here are collections for working with one or a bunch of records, here is the model itself with attributes-metators-listeners. And to reset the states, re-creation of the object is often used in the style return new static;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question