I can do "Meeting::firstOrCreate()" but that is horribly inefficient
Why ?
Yet it's the best choice for what you need.
If you really want to execute INSERT IGNORE, you can execute a raw query.
I have a database table in my database called "meetings" and a corresponding eloquent model called Meeting.
I am trying to do an INSERT IGNORE into the table.
I can do "Meeting::firstOrCreate()" but that is horribly inefficient, given I do not even want the model object itself.
However if I do "Meeting::createQuietly()" I get the following error:
Call to undefined method App\Models\Meeting::createQuietly()
Obviously I cannot do "Meeting::create()" because then I get an "Integrity constraint violation: 1062 Duplicate entry" error.
This is so basic that I cannot believe Laravel doesn't support it, so does anyone how I am supposed to do an INSERT IGNORE?
Just to clarify, I do not want "MyModel::firstOrCreate()" or "MyModel::createOrFirst()", I want to create the record if it doesn't exist and do nothing if it already exists, which translates to a SQL "INSERT IGNORE" statement.
Please or to participate in this conversation.