I'm having problems fetching data using Model::find()
with two conditions. I want to return one record that has the given member_id
AND its role
is guest
:
$member = CalendarMembers::find(["member_id" => $r->member_id, "role" => "guest"]);
But this isn't working. I have one user that when created, a new register is added to calendar_members
table specifying this user as parent
, yet, when attempting to fetch this user automatically created by just giving the member_id
, it will be fetched, which SHOULD NOT.
I cannot use other ways such as:
$member = \DB::table("calendar_members")->where([ ["member_id", "=", $r->member_id], ["role", "=", "guest"] ])->first();
Because then $member->delete()
or $member->destroy()
will throw an error saying either delete
or destroy
do not exist.