SNT93
SNT93

Reputation: 476

Constant Value for Every Row From DataBase Laravel Query Builder

I want to retrieve data (number of rows) from a DB in my Laravel project. Some of them should have Live Event as their status field and others should have Past Event as their status field.

How can I do that is Laravel Query Builder?

Example:

EventName    status
 a          'Live Event'
 b          'Live Event'
 c          'Past Event'
 d          'LiveEvent'
 e          'Past Event'

Upvotes: 0

Views: 1250

Answers (1)

SNT93
SNT93

Reputation: 476

Found an Answer..

$LatestpastEventsDetails = DB::table('event')->select('eventName', DB::raw('"live" as status'))->get();

do the same for live and , upcomming.. use Union to retrieve the full dataset

Upvotes: 2

Related Questions