jarektkaczyk / eloquence

Extensions for the Eloquent ORM
http://softonsofa.com
MIT License
1.09k stars 141 forks source link

Mapping does not works with firstOrCreate method #230

Closed SubrataM3 closed 4 years ago

SubrataM3 commented 6 years ago
// Example
User::firstOrCreate(['groupid' => '5']);

Error

(2/2) QueryExceptionSQLSTATE[42S22]: Column not found: 1054 Unknown column 'groupid' in 'where clause' (SQL: select * from users where (groupid = 5) limit 1)

// another example (gives question mark instead of value) $t = User::where('groupid', '5')->toSql();

select * from users where gid = ?

But for inserting data with User::Create method works fine.

I am using it on Lumen

Lumen (5.6.4) (Laravel Components 5.6.*)

Please help.

Thank you.

gfernandez-me commented 6 years ago

I have the same problem with array inside a where

if you use this: $this->model->where($criteria)->first();

You will have an error that columns doesn't exist

gfernandez-me commented 6 years ago

Solved using: $this->model->where('id', $id)->first()