Completed
Push — master ( ac13d3...9f68b4 )
by
unknown
01:57
created

AbstractModel::getCount()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace Taskforcedev\LaravelForum\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
7
/**
8
 * Class AbstractModel
9
 * Extends Illuminate\Database\Eloquent\Model
10
 *
11
 * @package Taskforcedev\LaravelForum\Models
12
 */
13
class AbstractModel extends Model
14
{
15
    use \Illuminate\Console\AppNamespaceDetectorTrait;
16
17
    public function getNamespace()
18
    {
19
        return $this->getAppNamespace();
20
    }
21
22
    /**
23
     * Helper method to get the count of items from a table.
24
     */
25
    public function getCount()
26
    {
27
        $count = \DB::select('select COUNT(*) as `count` from ' . $this->table);
28
        return $count[0]->count;
29
    }
30
}
31