In the official documentation I can see a method destroy where you can put a list of Primary Keys and it deletes all the data in the list.
ModelName::destroy([1,2,3]);
But what if we have a custom PK? I've tried to do it with a field called code which is a string but it says:
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'id' in 'where clause' (SQL: select * from `paises` where `id` in ())
Is there a way to tell Laravel that the primary key is not called id?
Something like
ModelName::destroy(['AL', 'ES', 'FR'], 'code');
codeis the actual primary key for the table, or are you just wanting to delete multiple records wherecodeisAL,ES orFR`?$table->string('code', 4)->primary();so It is the actual primary key