I have a table where the Primary Key
looks like this: 123456-789
in column id
.
When I request all the entries from my table using $allArray = $this->all()->toArray()
I have an issue. All the data arrives as expected but the id
now looks like this: 123456789
. The id
column is set as varchar(24) utf8_general_ci
in the database.
When I print_r()
my result from $all = $this->all()
(without ->toArray()
) I can see that the id
was fetched currently 123456-789
. Then I try to get the id
again like echo $all[1]->id
it is 123456789
.
Any help would be appreciated. Thank you :)
You should let your model know that primary key is not auto incrementing value else it will try to convert the primary key into an integer.
Simply add this to your model.
public $incrementing = false;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With