A
A
artyvr2015-02-07 22:22:02
Laravel
artyvr, 2015-02-07 22:22:02

How to count same values ​​in laravel 4 mysql table?

How to count same field values ​​in laravel 4 mysql table?
it is worth clarifying:
the values ​​of the field change over time, i.e. there is a table with a list of equipment models, which is supplemented and there is another table in which you need to calculate the number of each model.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
Crash, 2015-02-07
@Bandicoot

Something like this:
Post::where('field', '1')->get()->count();

A
artyvr, 2015-02-08
@artyvr

this helped:

$users = DB::table('users')
                     ->select(DB::raw('count(*) as user_count, status'))
                     ->groupBy('status')
                     ->get();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question