How update based on custom field?


#1

Hi,

i an new to userfrosting, please help me

i create a table with my custom field id which is auto incremented and primary. so that when i update record by using ->save() it give me error Column not found: 1054 Unknown column ‘id’ in ‘where clause’

because ‘id’ is not in my table so it dos not update or delete record

please let me know how i can update and delete on basis of my custom field
my table primary key column name id idCustomer

Thanks


#2

Can you show us the Table Class in your Migration, that you are using?

$table->increments(‘id’);

is the normal id-column… you should change it to

$table->increments(‘idCustomer’);

i think… not tried, but this could be the way


#3

In Eloquent, it’s usually a really good idea to use id as your primary key. This is the convention that is used in most tutorials and third-party code you will find.

That being said, you can theoretically use an alternate primary key, but you need to specify protected $primaryKey in your model definition. See https://laravel.com/docs/5.4/eloquent#eloquent-model-conventions, specifically the section “Primary Keys”.


#4

yes, i am new to laravel as well so that i did not tried this
but it worked
thanks Naddy