Reputation: 2457
In Laravel, I can get the rows from a selected column in MySQL by a Laravel query.
$data = DB::query('select engagements from csv2');
However, I wonder how can I write this using Eloquent?
Upvotes: 1
Views: 4174
Reputation: 1279
Egill's answer works, however I find the below more readable.
$email = User::select('email')->get();
And for your follow up question.
Can i query rows that only has value on it
$email = User::select('email')
->where('email', '!=', '')
->get();
Upvotes: 1
Reputation: 71
$data = Model::get(array('engagements'));
For example if I only want to get the E-mail for a user;
$email = User::get(array('email'));
Upvotes: 3