title: Count a field in database
body: <p>I want to count a field name 'leave_policy' depending on the name of 'leave_policy' and I am using joins to do it. My database is like this
  <a href="https://imgur.com/a/gR3Dw" rel="nofollow noreferrer">https://imgur.com/a/gR3Dw</a> </p>
  
  <p>and I want to show count in applied section. For example if I want to count all "Urgent Leaves" and "Paternal Leaves" seperately I have applied till now.  <a href="https://imgur.com/a/dvjuX" rel="nofollow noreferrer">https://imgur.com/a/dvjuX</a></p>
  
  <pre><code>    $join = DB::table('leaves_policy')
          -&gt;join('leaves_policies', 'leaves_policy.leave_policy', '=', 'leaves_policies.title')
          -&gt;join('leaves_requests', 'leaves_policy.requested_by' , '=', 'leaves_requests.requested_by')
          -&gt;select('leaves_policy.*', 'leaves_policies.title', 'leaves_policies.total_no_of_leaves_allowed_per_year',
              'leaves_policies.no_of_months_leaves_valid', 'leaves_policies.max_leaves_per_month', 'leaves_policies.max_con_leaves_per_month',
              'leaves_requests.leave_status', DB::raw('COUNT(leaves_policy.leave_policy) as count'))
          -&gt;groupBy('id')
          -&gt;get();
  </code></pre>