I want to add DB::raw() with specific where clause to existing query.
I have this Query:
protected static $type =
[
'daily' => 1,
'weekly' => 2,
'montly' => 3,
];
$revenuedetails = DB::table("users")
->select("users.username", "users.email",DB::raw("DATE(users.created_at) as subscription_date"))
->where('users.plan', self::$type[$plan] ?? null);
But I want to add this:
DB::raw("DATE(users.created_at) as expired_date"))
where('users.plan_status', 0)
It whould be immediately beside
DB::raw("DATE(users.created_at) as subscription_date"))
Hence the the structure will now be
username | email | subscription_date | expired_date
I want to add
DB::raw("DATE(users.created_at) as expired_date"))
with its own specific where clause
where('users.plan_status', 0)
to the existing query.
Please note that
where('users.plan', self::$type[$plan] ?? null)
is the overall where clause.
Then end result should be
username | email | subscription_date | expired_date