Welcome Guest, Not a member yet? Register   Sign In
array_column does not work with Entity
#8

(This post was last modified: 06-04-2024, 11:16 PM by warcooft.)

Looks like this is a bug:
Different behavior between models with primary key ID and not ID or something else when using find() method.

[Image: PvtOaA.jpg]


[Image: pPVEBu.jpg]
in NotificationSettingModel I use user_id as $primary_key

andĀ UserModel uses id as $primary_key

it looks like the find() method uses id as the default reference.

why doesn't the find() method detect the primary key assigned to the model?

it would be more efficient than having to create chained methods like this model(NotificationSettingModel::class)->whereIn(user_id, [1,2,3])->findAll();

-------------------------------------------------------

PHP Code:
$notifications model(NotificationSettingModel::class)->find([46]);
$notifications model(NotificationSettingModel::class)->find(); 


The query above produces the same output as in the screenshot, is it because the method does not find the ID column in a table?
my expected output is It should returns an array of Entities.

[Image: lpxw0q.jpg]
after I debug again. the result query of this codeĀ model(NotificationSettingModel::class)->withScheduleNotification()->find([1, 2]);

meets my expectations, but why is the output object an entity, not an array of an entity?
@xxxx[{::::::::::::::::::::::::::::::::>
Reply


Messages In This Thread
RE: array_column does not work with Entity - by warcooft - 06-04-2024, 10:24 PM



Theme © iAndrew 2016 - Forum software by © MyBB