Here are the Custom Queries In laravel, please check it:
1. Date Format in laravel:
DB::raw('DATE_FORMAT(orders.timestamp_order_made, "%m/%d/%Y") as order_date')
2. Case Statement In Laravel
DB::raw("
CASE orders.status
WHEN '1' THEN 'Order Placed'
WHEN '2' THEN 'Allocated'
WHEN '3' THEN 'Rejected'
WHEN '4' THEN 'Failure'
WHEN '5' THEN 'Accepted'
WHEN '6' THEN 'Delivered'
WHEN '7' THEN 'Accepted by dispensary'
WHEN '8' THEN 'Pickup at dispensary'
ELSE 'NO'
END as order_status
")
3. Concatenation in Laravel:
DB::raw("CONCAT_WS(' ',users.first_name, users.last_name) AS customer_name")
Enjoy☺
1. Date Format in laravel:
DB::raw('DATE_FORMAT(orders.timestamp_order_made, "%m/%d/%Y") as order_date')
2. Case Statement In Laravel
DB::raw("
CASE orders.status
WHEN '1' THEN 'Order Placed'
WHEN '2' THEN 'Allocated'
WHEN '3' THEN 'Rejected'
WHEN '4' THEN 'Failure'
WHEN '5' THEN 'Accepted'
WHEN '6' THEN 'Delivered'
WHEN '7' THEN 'Accepted by dispensary'
WHEN '8' THEN 'Pickup at dispensary'
ELSE 'NO'
END as order_status
")
3. Concatenation in Laravel:
DB::raw("CONCAT_WS(' ',users.first_name, users.last_name) AS customer_name")
Enjoy☺
Can you please add more queries for laravel.
ReplyDeleteThank you
Yes I will add in future posts :)
Delete