Passed
Push — main ( 1c11cf...b7c84c )
by Nobufumi
02:42
created

BaseModel::getQuery()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Jidaikobo\Kontiki\Models;
4
5
use Illuminate\Database\Connection;
6
use Illuminate\Database\Query\Builder;
7
8
use Jidaikobo\Kontiki\Core\Database;
9
use Jidaikobo\Kontiki\Models\BaseModelTraits;
10
11
/**
12
 * BaseModel provides common CRUD operations for database interactions.
13
 * Extend this class to create specific models for different database tables.
14
 */
15
abstract class BaseModel implements ModelInterface
16
{
17
    use BaseModelTraits\FieldDefinitionTrait;
18
    use BaseModelTraits\SearchTrait;
19
    use BaseModelTraits\UtilsTrait;
0 ignored issues
show
Bug introduced by
The trait Jidaikobo\Kontiki\Models...eModelTraits\UtilsTrait requires the property $id which is not provided by Jidaikobo\Kontiki\Models\BaseModel.
Loading history...
20
    use BaseModelTraits\ValidateTrait;
21
22
    protected string $table;
23
    protected string $postType = '';
24
    protected string $deleteType = 'hardDelete';
25
    protected Connection $db;
26
27
    public function __construct(Database $db)
28
    {
29
        $this->db = $db->getConnection();
30
    }
31
32
    public function getQuery(): Builder
33
    {
34
        return $this->db->table($this->table);
35
    }
36
37
    public function getDeleteType(): string
38
    {
39
        return $this->deleteType;
40
    }
41
42
    public function getTableName(): string
43
    {
44
        return $this->table;
45
    }
46
47
    public function getPostType(): string
48
    {
49
        return $this->postType;
50
    }
51
}
52