HtmlBlockRepository::selectOneByShopIdAndSlug()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 2
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Hideyo\Ecommerce\Framework\Services\HtmlBlock\Entity;
4
5
use Hideyo\Ecommerce\Framework\Services\HtmlBlock\Entity\HtmlBlock;
6
use Hideyo\Ecommerce\Framework\Services\BaseRepository;
7
8
class HtmlBlockRepository extends BaseRepository 
9
{
10
    protected $model;
11
12
    public function __construct(HtmlBlock $model)
13
    {
14
        $this->model = $model;
15
    }
16
17
    function selectAllActiveByShopId($shopId)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
18
    {
19
         return $this->model->where('shop_id', $shopId)->get();
20
    }
21
22
    function selectOneByShopIdAndSlug($shopId, $slug)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
23
    {
24
        $result = $this->model->where('shop_id', $shopId)->where('slug', $slug)->get();
25
        
26
        if ($result->isEmpty()) {
27
            return false;
28
        }
29
        return $result->first();
30
    }
31
32
    public function selectOneByShopIdAndPosition($position, $shopId)
33
    {
34
        $result = $this->model->where('shop_id', $shopId)->where('position', $position)->get();
35
        
36
        if ($result->isEmpty()) {
37
            return false;
38
        }
39
        return $result->first();
40
    } 
41
}